Interface ItemVariant
- All Superinterfaces:
TransferVariant<Item>
An immutable count-less ItemStack, i.e. an immutable association of an item and its data components.
Do not implement, use the static of(...) functions instead.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<ItemVariant> static final PacketCodec<RegistryByteBuf, ItemVariant> -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemVariantblank()Retrieve a blank ItemVariant.default ItemgetItem()Return the item of this variant.default RegistryEntry<Item> default booleanReturn true if the item and tag of this variant match those of the passed stack, and false otherwise.static ItemVariantof(ItemConvertible item) Retrieve an ItemVariant with an item and without a tag.static ItemVariantof(ItemConvertible item, ComponentChanges components) Retrieve an ItemVariant with an item and an optional tag.static ItemVariantRetrieve an ItemVariant with the item and tag of a stack.default ItemStacktoStack()Create a new item stack with count 1 from this variant.default ItemStacktoStack(int count) Create a new item stack from this variant.withComponentChanges(ComponentChanges changes) Creates a copy of this ItemVariant with the provided component changes applied.Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant
componentsMatch, getComponentMap, getComponents, getObject, hasComponents, isBlank, isOf
-
Field Details
-
CODEC
-
PACKET_CODEC
-
-
Method Details
-
blank
Retrieve a blank ItemVariant. -
of
Retrieve an ItemVariant with the item and tag of a stack. -
of
Retrieve an ItemVariant with an item and without a tag. -
of
Retrieve an ItemVariant with an item and an optional tag. -
matches
Return true if the item and tag of this variant match those of the passed stack, and false otherwise. -
getItem
Return the item of this variant. -
getRegistryEntry
-
toStack
Create a new item stack with count 1 from this variant. -
toStack
Create a new item stack from this variant.- Parameters:
count- The count of the returned stack. It may lead to counts higher than maximum stack size.
-
withComponentChanges
Creates a copy of this ItemVariant with the provided component changes applied.- Specified by:
withComponentChangesin interfaceTransferVariant<Item>- Parameters:
changes- the changes to apply- Returns:
- the new variant with the changes applied
- See Also:
-