Package net.minecraft.item
Class FoodComponent.Builder
java.lang.Object
net.minecraft.item.FoodComponent.Builder
- Enclosing class:
- FoodComponent
public static class FoodComponent.Builder extends Object
-
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 Constructor Description Builder()
-
Method Summary
Modifier and Type Method Description FoodComponent.Builder
alwaysEdible()
Specifies that a food item can be eaten when the current hunger bar is full.FoodComponent
build()
FoodComponent.Builder
hunger(int hunger)
Specifies the amount of hunger a food item will fill.FoodComponent.Builder
meat()
Specifies that a food item can be fed to dogs.FoodComponent.Builder
saturationModifier(float saturationModifier)
Specifies the saturation modifier of a food item.FoodComponent.Builder
snack()
Specifies that a food item is snack-like and is eaten quickly.FoodComponent.Builder
statusEffect(StatusEffectInstance effect, float chance)
Specifies a status effect to apply to an entity when a food item is consumed.
-
Field Details
-
hunger
private int hunger -
saturationModifier
private float saturationModifier -
meat
private boolean meat -
alwaysEdible
private boolean alwaysEdible -
snack
private boolean snack -
statusEffects
-
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
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
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
Specifies that a food item can be fed to dogs. -
alwaysEdible
Specifies that a food item can be eaten when the current hunger bar is full. -
snack
Specifies that a food item is snack-like and is eaten quickly. -
statusEffect
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 applychance
- the chance the status effect is applied, on a scale of0.0F
to1.0F
-
build
-