Package net.minecraft.item
Class FoodComponent
java.lang.Object
net.minecraft.item.FoodComponent
public class FoodComponent extends Object
Represents the components that make up the properties of a food item.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFoodComponent.Builder -
Field Summary
Fields Modifier and Type Field Description private booleanalwaysEdibleprivate inthungerprivate booleanmeatprivate floatsaturationModifierprivate booleansnackprivate List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>>statusEffects -
Constructor Summary
Constructors Modifier Constructor Description privateFoodComponent(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> statusEffects) -
Method Summary
Modifier and Type Method Description intgetHunger()Gets the amount of hunger a food item will fill.floatgetSaturationModifier()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.booleanisAlwaysEdible()Checks if a food item can be eaten when the current hunger bar is full.booleanisMeat()Checks if a food item can be fed to dogs.booleanisSnack()Checks if a food item is snack-like and is eaten quickly.
-
Field Details
-
hunger
private final int hunger -
saturationModifier
private final float saturationModifier -
meat
private final boolean meat -
alwaysEdible
private final boolean alwaysEdible -
snack
private final boolean snack -
statusEffects
-
-
Constructor Details
-
FoodComponent
private FoodComponent(int hunger, float saturationModifier, boolean meat, boolean alwaysEdible, boolean snack, List<com.mojang.datafixers.util.Pair<StatusEffectInstance,Float>> statusEffects)
-
-
Method Details
-
getHunger
public int getHunger()Gets the amount of hunger a food item will fill.One hunger is equivalent to half of a hunger bar icon.
-
getSaturationModifier
public float getSaturationModifier()Gets the saturation modifier of a food item.This value is typically used to determine how long a player can sustain the current hunger value before the hunger is used.
-
isMeat
public boolean isMeat()Checks if a food item can be fed to dogs. -
isAlwaysEdible
public boolean isAlwaysEdible()Checks if a food item can be eaten when the current hunger bar is full. -
isSnack
public boolean isSnack()Checks if a food item is snack-like and is eaten quickly. -
getStatusEffects
Gets a list of all status effect instances that may be applied when a food item is consumed.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.0Fand1.0F.
-