Record Class ItemStackTemplate
java.lang.Object
java.lang.Record
net.minecraft.world.item.ItemStackTemplate
- All Implemented Interfaces:
DataComponentGetter, TypedInstance<Item>, ItemInstance, ItemInstanceExtension
public record ItemStackTemplate(Holder<Item> item, int count, DataComponentPatch components)
extends Record
implements ItemInstance
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ItemStackTemplate> private final DataComponentPatchThe field for thecomponentsrecord component.private final intThe field for thecountrecord component.The field for theitemrecord component.private static final org.slf4j.Loggerstatic final com.mojang.serialization.MapCodec<ItemStackTemplate> static final StreamCodec<RegistryFriendlyByteBuf, ItemStackTemplate> Fields inherited from interface ItemInstance
FIELD_COMPONENTS, FIELD_COUNT, FIELD_ID -
Constructor Summary
ConstructorsConstructorDescriptionItemStackTemplate(Holder<Item> item) ItemStackTemplate(Holder<Item> item, int count) ItemStackTemplate(Holder<Item> item, int count, DataComponentPatch components) Creates an instance of aItemStackTemplaterecord class.ItemStackTemplate(Holder<Item> item, DataComponentPatch patch) ItemStackTemplate(Item item) ItemStackTemplate(Item item, int count) ItemStackTemplate(Item item, int count, DataComponentPatch patch) ItemStackTemplate(Item item, DataComponentPatch patch) -
Method Summary
Modifier and TypeMethodDescriptionapply(int count, DataComponentPatch additionalPatch) apply(DataComponentPatch additionalPatch) Returns the value of thecomponentsrecord component.intcount()Returns the value of thecountrecord component.create()final booleanIndicates whether some other object is "equal to" this one.static ItemStackTemplatefromNonEmptyStack(ItemStack itemStack) <T> @Nullable Tget(DataComponentType<? extends T> type) final inthashCode()Returns a hash code value for this object.item()Returns the value of theitemrecord component.final StringtoString()Returns a string representation of this record class.private ItemStackwithCount(int count) Methods inherited from interface DataComponentGetter
get, getOrDefault, getOrDefault, getTyped, has, hasMethods inherited from interface ItemInstance
getMaxStackSizeMethods inherited from interface ItemInstanceExtension
canPerformAction, getEnchantmentLevel, getTagEnchantments
-
Field Details
-
item
-
count
private final int countThe field for thecountrecord component. -
components
The field for thecomponentsrecord component. -
LOGGER
private static final org.slf4j.Logger LOGGER -
MAP_CODEC
-
CODEC
-
STREAM_CODEC
-
-
Constructor Details
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
-
ItemStackTemplate
Creates an instance of aItemStackTemplaterecord class.- Parameters:
item- the value for theitemrecord componentcount- the value for thecountrecord componentcomponents- the value for thecomponentsrecord component
-
-
Method Details
-
fromNonEmptyStack
-
withCount
-
create
-
validate
-
apply
-
apply
-
typeHolder
- Specified by:
typeHolderin interfaceTypedInstance<Item>
-
get
- Specified by:
getin interfaceDataComponentGetter
-
toString
-
hashCode
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
item
-
count
public int count()Returns the value of thecountrecord component.- Specified by:
countin interfaceItemInstance- Returns:
- the value of the
countrecord component
-
components
Returns the value of thecomponentsrecord component.- Returns:
- the value of the
componentsrecord component
-