Interface TransferVariant<O>

Type Parameters:
O - The type of the immutable object instance, for example Item or Fluid.
All Known Subinterfaces:
FluidVariant, ItemVariant

@Experimental @Deprecated public interface TransferVariant<O>
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 association of an immutable object instance (for example Item or Fluid) and an optional NBT tag.

This is exposed for convenience for code that needs to be generic across multiple transfer variants, but note that a Storage is not necessarily bound to TransferVariant. Its generic parameter can be any immutable object.

Transfer variants must always be compared with #equals, never by reference! #hashCode is guaranteed to be correct and constant time independently of the size of the NBT.

  • Method Summary

    Modifier and Type
    Method
    Description
    default @Nullable net.minecraft.nbt.NbtCompound
    Deprecated.
    Return a copy of the tag of this variant, or null if this variant doesn't have a tag.
    @Nullable net.minecraft.nbt.NbtCompound
    Deprecated.
    Return the underlying tag.
    Deprecated.
    Return the immutable object instance of this variant.
    default boolean
    Deprecated.
    Return true if this variant has a tag, false otherwise.
    boolean
    Deprecated.
    Return true if this variant is blank, and false otherwise.
    default boolean
    isOf​(O object)
    Deprecated.
    Return true if the object of this variant matches the passed fluid.
    default boolean
    nbtMatches​(@Nullable net.minecraft.nbt.NbtCompound other)
    Deprecated.
    Return true if the tag of this variant matches the passed tag, and false otherwise.
    net.minecraft.nbt.NbtCompound
    Deprecated.
    Save this variant into an NBT compound tag.
    void
    toPacket​(net.minecraft.network.PacketByteBuf buf)
    Deprecated.
    Write this variant into a packet byte buffer.
  • Method Details

    • isBlank

      boolean isBlank()
      Deprecated.
      Return true if this variant is blank, and false otherwise.
    • getObject

      O getObject()
      Deprecated.
      Return the immutable object instance of this variant.
    • getNbt

      @Nullable @Nullable net.minecraft.nbt.NbtCompound getNbt()
      Deprecated.
      Return the underlying tag.

      NEVER MUTATE THIS NBT TAG, if you need to mutate it you can use copyNbt() to retrieve a copy instead.

    • hasNbt

      default boolean hasNbt()
      Deprecated.
      Return true if this variant has a tag, false otherwise.
    • nbtMatches

      default boolean nbtMatches(@Nullable @Nullable net.minecraft.nbt.NbtCompound other)
      Deprecated.
      Return true if the tag of this variant matches the passed tag, and false otherwise.

      Note: True is returned if both tags are null.

    • isOf

      default boolean isOf(O object)
      Deprecated.
      Return true if the object of this variant matches the passed fluid.
    • copyNbt

      @Nullable default @Nullable net.minecraft.nbt.NbtCompound copyNbt()
      Deprecated.
      Return a copy of the tag of this variant, or null if this variant doesn't have a tag.

      Note: Use nbtMatches(net.minecraft.nbt.NbtCompound) if you only need to check for custom tag equality, or getNbt() if you don't need to mutate the tag.

    • toNbt

      net.minecraft.nbt.NbtCompound toNbt()
      Deprecated.
      Save this variant into an NBT compound tag. Subinterfaces should have a matching static fromNbt.

      Note: This is safe to use for persisting data as objects are saved using their full Identifier.

    • toPacket

      void toPacket(net.minecraft.network.PacketByteBuf buf)
      Deprecated.
      Write this variant into a packet byte buffer. Subinterfaces should have a matching static fromPacket.

      Implementation note: Objects are saved using their raw registry integer id.