Package net.minecraft.world.food
Record Class FoodProperties
java.lang.Object
java.lang.Record
net.minecraft.world.food.FoodProperties
- All Implemented Interfaces:
ConsumableListener
public record FoodProperties(int nutrition, float saturation, boolean canAlwaysEat)
extends Record
implements ConsumableListener
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanThe field for thecanAlwaysEatrecord component.static final com.mojang.serialization.Codec<FoodProperties> static final StreamCodec<RegistryFriendlyByteBuf, FoodProperties> private final intThe field for thenutritionrecord component.private final floatThe field for thesaturationrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionFoodProperties(int nutrition, float saturation, boolean canAlwaysEat) Creates an instance of aFoodPropertiesrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of thecanAlwaysEatrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of thenutritionrecord component.voidonConsume(Level pLevel, LivingEntity pEntity, ItemStack pStack, Consumable pConsumable) floatReturns the value of thesaturationrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
nutrition
private final int nutritionThe field for thenutritionrecord component. -
saturation
private final float saturationThe field for thesaturationrecord component. -
canAlwaysEat
private final boolean canAlwaysEatThe field for thecanAlwaysEatrecord component. -
DIRECT_CODEC
-
DIRECT_STREAM_CODEC
-
-
Constructor Details
-
FoodProperties
public FoodProperties(int nutrition, float saturation, boolean canAlwaysEat) Creates an instance of aFoodPropertiesrecord class.- Parameters:
nutrition- the value for thenutritionrecord componentsaturation- the value for thesaturationrecord componentcanAlwaysEat- the value for thecanAlwaysEatrecord component
-
-
Method Details
-
onConsume
- Specified by:
onConsumein interfaceConsumableListener
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
nutrition
public int nutrition()Returns the value of thenutritionrecord component.- Returns:
- the value of the
nutritionrecord component
-
saturation
public float saturation()Returns the value of thesaturationrecord component.- Returns:
- the value of the
saturationrecord component
-
canAlwaysEat
public boolean canAlwaysEat()Returns the value of thecanAlwaysEatrecord component.- Returns:
- the value of the
canAlwaysEatrecord component
-