Package net.minecraft.component.type
Record Class FoodComponent
java.lang.Object
java.lang.Record
net.minecraft.component.type.FoodComponent
- Record Components:
nutrition-saturation-canAlwaysEat-
- All Implemented Interfaces:
Consumable
public record FoodComponent(int nutrition, float saturation, boolean canAlwaysEat)
extends Record
implements Consumable
Represents the components that make up the properties of a food item.
- Mappings:
Namespace Name named net/minecraft/component/type/FoodComponentintermediary net/minecraft/class_4174official csanamed nutritionintermediary comp_2491official cnamed saturationintermediary comp_2492official dnamed canAlwaysEatintermediary comp_2493official e
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanThe field for thecanAlwaysEatrecord component.static final com.mojang.serialization.Codec<FoodComponent> private final intThe field for thenutritionrecord component.static final PacketCodec<RegistryByteBuf, FoodComponent> private final floatThe field for thesaturationrecord component. -
Constructor Summary
ConstructorsConstructorDescriptionFoodComponent(int nutrition, float saturation, boolean canAlwaysEat) Creates an instance of aFoodComponentrecord 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(World world, LivingEntity user, ItemStack stack, ConsumableComponent consumable) 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. -
CODEC
- Mappings:
Namespace Name Mixin selector named CODECLnet/minecraft/component/type/FoodComponent;CODEC:Lcom/mojang/serialization/Codec;intermediary field_49992Lnet/minecraft/class_4174;field_49992:Lcom/mojang/serialization/Codec;official aLcsa;a:Lcom/mojang/serialization/Codec;
-
PACKET_CODEC
- Mappings:
Namespace Name Mixin selector named PACKET_CODECLnet/minecraft/component/type/FoodComponent;PACKET_CODEC:Lnet/minecraft/network/codec/PacketCodec;intermediary field_49993Lnet/minecraft/class_4174;field_49993:Lnet/minecraft/class_9139;official bLcsa;b:Lyn;
-
-
Constructor Details
-
FoodComponent
public FoodComponent(int nutrition, float saturation, boolean canAlwaysEat) Creates an instance of aFoodComponentrecord class.- Parameters:
nutrition- the value for thenutritionrecord componentsaturation- the value for thesaturationrecord componentcanAlwaysEat- the value for thecanAlwaysEatrecord component
-
-
Method Details
-
onConsume
public void onConsume(World world, LivingEntity user, ItemStack stack, ConsumableComponent consumable) - Specified by:
onConsumein interfaceConsumable- Mappings:
Namespace Name Mixin selector named onConsumeLnet/minecraft/component/type/Consumable;onConsume(Lnet/minecraft/world/World;Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/component/type/ConsumableComponent;)Vintermediary method_62831Lnet/minecraft/class_10127;method_62831(Lnet/minecraft/class_1937;Lnet/minecraft/class_1309;Lnet/minecraft/class_1799;Lnet/minecraft/class_10124;)Vofficial aLcyx;a(Ldgj;Lbvi;Lcwq;Lcyw;)V
-
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
-