Class FoodComponent.Builder

java.lang.Object
net.minecraft.item.FoodComponent.Builder
Enclosing class:
FoodComponent

public static class FoodComponent.Builder
extends Object
  • Field Details

    • hunger

      private int hunger
    • saturationModifier

      private float saturationModifier
    • meat

      private boolean meat
    • alwaysEdible

      private boolean alwaysEdible
    • snack

      private boolean snack
    • statusEffects

      private final List<com.mojang.datafixers.util.Pair<StatusEffectInstance,​Float>> statusEffects
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • hunger

      public FoodComponent.Builder hunger​(int hunger)
      Specifies the amount of hunger a food item will fill.

      One hunger is equivalent to half of a hunger bar icon.

      Parameters:
      hunger - the amount of hunger
    • saturationModifier

      public FoodComponent.Builder saturationModifier​(float saturationModifier)
      Specifies 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.

      Parameters:
      saturationModifier - the saturation modifier
    • meat

      public FoodComponent.Builder meat()
      Specifies that a food item can be fed to dogs.
    • alwaysEdible

      public FoodComponent.Builder alwaysEdible()
      Specifies that a food item can be eaten when the current hunger bar is full.
    • snack

      public FoodComponent.Builder snack()
      Specifies that a food item is snack-like and is eaten quickly.
    • statusEffect

      public FoodComponent.Builder statusEffect​(StatusEffectInstance effect, float chance)
      Specifies a status effect to apply to an entity when a food item is consumed. This method may be called multiple times to apply several status effects when food is consumed.
      Parameters:
      effect - the effect instance to apply
      chance - the chance the status effect is applied, on a scale of 0.0F to 1.0F
    • build

      public FoodComponent build()