public class FoodComponent extends Object
Modifier and Type | Class and Description |
---|---|
static class |
FoodComponent.Builder |
Modifier and Type | Field and Description |
---|---|
private boolean |
alwaysEdible |
private int |
hunger |
private boolean |
meat |
private float |
saturationModifier |
private boolean |
snack |
private List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> |
statusEffects |
Modifier | Constructor and Description |
---|---|
private |
FoodComponent(int hunger,
float saturationModifier,
boolean meat,
boolean alwaysEdible,
boolean snack,
List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> statusEffects) |
Modifier and Type | Method and Description |
---|---|
int |
getHunger()
Gets the amount of hunger a food item will fill.
|
float |
getSaturationModifier()
Gets the saturation modifier of a food item.
|
List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> |
getStatusEffects()
Gets a list of all status effect instances that may be applied when a food item is consumed.
|
boolean |
isAlwaysEdible()
Checks if a food item can be eaten when the current hunger bar is full.
|
boolean |
isMeat()
Checks if a food item can be fed to dogs.
|
boolean |
isSnack()
Checks if a food item is snack-like and is eaten quickly.
|
private final int hunger
private final float saturationModifier
private final boolean meat
private final boolean alwaysEdible
private final boolean snack
private final List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> statusEffects
private FoodComponent(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> statusEffects)
public int getHunger()
One hunger is equivalent to half of a hunger bar icon.
public float getSaturationModifier()
This value is typically used to determine how long a player can sustain the current hunger value before the hunger is used.
public boolean isMeat()
public boolean isAlwaysEdible()
public boolean isSnack()
public List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> getStatusEffects()
The first value in the pair is the status effect instance to be applied.
The second value is the chance the status effect gets applied, on a scale between 0.0F
and 1.0F
.