Interface ItemVariant

All Superinterfaces:
TransferVariant<net.minecraft.item.Item>

@Experimental @Deprecated @NonExtendable public interface ItemVariant extends TransferVariant<net.minecraft.item.Item>
Deprecated.
Experimental feature, we reserve the right to remove or change it without further notice. The transfer API is a complex addition, and we want to be able to correct possible design mistakes.
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 Type
    Method
    Description
    Deprecated.
    Retrieve a blank ItemVariant.
    fromNbt​(net.minecraft.nbt.NbtCompound nbt)
    Deprecated.
    Deserialize a variant from an NBT compound tag, assuming it was serialized using TransferVariant.toNbt().
    fromPacket​(net.minecraft.network.PacketByteBuf buf)
    Deprecated.
    Write a variant from a packet byte buffer, assuming it was serialized using TransferVariant.toPacket(net.minecraft.network.PacketByteBuf).
    default net.minecraft.item.Item
    Deprecated.
    Return the item of this variant.
    default boolean
    matches​(net.minecraft.item.ItemStack stack)
    Deprecated.
    Return true if the item and tag of this variant match those of the passed stack, and false otherwise.
    of​(net.minecraft.item.ItemConvertible item)
    Deprecated.
    Retrieve an ItemVariant with an item and without a tag.
    of​(net.minecraft.item.ItemConvertible item, @Nullable net.minecraft.nbt.NbtCompound tag)
    Deprecated.
    Retrieve an ItemVariant with an item and an optional tag.
    of​(net.minecraft.item.ItemStack stack)
    Deprecated.
    Retrieve an ItemVariant with the item and tag of a stack.
    default net.minecraft.item.ItemStack
    Deprecated.
    Create a new item stack with count 1 from this variant.
    default net.minecraft.item.ItemStack
    toStack​(int count)
    Deprecated.
    Create a new item stack from this variant.

    Methods inherited from interface net.fabricmc.fabric.api.transfer.v1.storage.TransferVariant

    copyNbt, getNbt, getObject, hasNbt, isBlank, isOf, nbtMatches, toNbt, toPacket
  • Method Details

    • blank

      static ItemVariant blank()
      Deprecated.
      Retrieve a blank ItemVariant.
    • of

      static ItemVariant of(net.minecraft.item.ItemStack stack)
      Deprecated.
      Retrieve an ItemVariant with the item and tag of a stack.
    • of

      static ItemVariant of(net.minecraft.item.ItemConvertible item)
      Deprecated.
      Retrieve an ItemVariant with an item and without a tag.
    • of

      static ItemVariant of(net.minecraft.item.ItemConvertible item, @Nullable @Nullable net.minecraft.nbt.NbtCompound tag)
      Deprecated.
      Retrieve an ItemVariant with an item and an optional tag.
    • matches

      default boolean matches(net.minecraft.item.ItemStack stack)
      Deprecated.
      Return true if the item and tag of this variant match those of the passed stack, and false otherwise.
    • getItem

      default net.minecraft.item.Item getItem()
      Deprecated.
      Return the item of this variant.
    • toStack

      default net.minecraft.item.ItemStack toStack()
      Deprecated.
      Create a new item stack with count 1 from this variant.
    • toStack

      default net.minecraft.item.ItemStack toStack(int count)
      Deprecated.
      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

      static ItemVariant fromNbt(net.minecraft.nbt.NbtCompound nbt)
      Deprecated.
      Deserialize a variant from an NBT compound tag, assuming it was serialized using TransferVariant.toNbt(). If an error occurs during deserialization, it will be logged with the DEBUG level, and a blank variant will be returned.
    • fromPacket

      static ItemVariant fromPacket(net.minecraft.network.PacketByteBuf buf)
      Deprecated.
      Write a variant from a packet byte buffer, assuming it was serialized using TransferVariant.toPacket(net.minecraft.network.PacketByteBuf).