Interface ItemVariant
- All Superinterfaces:
TransferVariant<Item>
An immutable count-less ItemStack, i.e. an immutable association of an item and an optional NBT compound tag.
Do not implement, use the static of(...)
functions instead.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ItemVariant
blank()
Retrieve a blank ItemVariant.static ItemVariant
fromNbt
(NbtCompound nbt) Deserialize a variant from an NBT compound tag, assuming it was serialized usingTransferVariant.toNbt()
.static ItemVariant
fromPacket
(PacketByteBuf buf) Write a variant from a packet byte buffer, assuming it was serialized usingTransferVariant.toPacket(net.minecraft.network.PacketByteBuf)
.default Item
getItem()
Return the item of this variant.default boolean
Return true if the item and tag of this variant match those of the passed stack, and false otherwise.static ItemVariant
of
(ItemConvertible item) Retrieve an ItemVariant with an item and without a tag.static ItemVariant
of
(ItemConvertible item, @Nullable NbtCompound tag) Retrieve an ItemVariant with an item and an optional tag.static ItemVariant
Retrieve an ItemVariant with the item and tag of a stack.default ItemStack
toStack()
Create a new item stack with count 1 from this variant.default ItemStack
toStack
(int count) Create a new item stack from this variant.Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant
copyNbt, copyOrCreateNbt, getNbt, getObject, hasNbt, isBlank, isOf, nbtMatches, toNbt, toPacket
-
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. -
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.
-
fromNbt
Deserialize a variant from an NBT compound tag, assuming it was serialized usingTransferVariant.toNbt()
. If an error occurs during deserialization, it will be logged with the DEBUG level, and a blank variant will be returned. -
fromPacket
Write a variant from a packet byte buffer, assuming it was serialized usingTransferVariant.toPacket(net.minecraft.network.PacketByteBuf)
.
-