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 class
FoodComponent.Builder
-
Field Summary
Fields Modifier and Type Field 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
-
Constructor Summary
Constructors Modifier Constructor Description private
FoodComponent(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 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.
-
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.0F
and1.0F
.
-