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.
  • 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

      private final List<com.mojang.datafixers.util.Pair<StatusEffectInstance,​Float>> 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

      public 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.

      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.