Skip to main content

yog_core/
food.rs

1//! What eating an item gives, as the game says (`yog_event`'s
2//! `item::Food`): the same on every version, each host reading its own
3//! game's food data — mods' food included.
4
5use yog_data::{Atom, Schema};
6
7/// An item's food: what it fills, how long it holds off hunger, what it does.
8#[derive(Debug, Clone, PartialEq, Schema)]
9pub struct Food {
10    /// Hunger points it fills (a drumstick is 2).
11    pub nutrition: i32,
12    /// Saturation it gives, in points (not the older versions' modifier).
13    pub saturation: f32,
14    /// Eaten even when full (a golden apple).
15    pub always_edible: bool,
16    /// Eaten faster than most (dried kelp).
17    pub fast: bool,
18    /// The effects it may give.
19    pub effects: Vec<FoodEffect>,
20}
21
22/// An effect eating may give.
23#[derive(Debug, Clone, PartialEq, Schema)]
24pub struct FoodEffect {
25    /// The effect's id (`minecraft:poison`).
26    pub effect: Atom,
27    /// How likely, 0 to 1.
28    pub chance: f32,
29    /// Whether the game counts it good for who has it (regeneration) or not (poison).
30    pub beneficial: bool,
31}