Interface TransferVariant<O>
- Type Parameters:
O- The type of the immutable object instance, for exampleItemorFluid.
- All Known Subinterfaces:
FluidVariant,ItemVariant
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 TypeMethodDescriptiondefault @Nullable net.minecraft.nbt.NbtCompoundcopyNbt()Deprecated.Return a copy of the tag of this variant, ornullif this variant doesn't have a tag.@Nullable net.minecraft.nbt.NbtCompoundgetNbt()Deprecated.Return the underlying tag.Deprecated.Return the immutable object instance of this variant.default booleanhasNbt()Deprecated.Return true if this variant has a tag, false otherwise.booleanisBlank()Deprecated.Return true if this variant is blank, and false otherwise.default booleanDeprecated.Returntrueif the object of this variant matches the passed fluid.default booleannbtMatches(@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.NbtCompoundtoNbt()Deprecated.Save this variant into an NBT compound tag.voidtoPacket(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
Deprecated.Returntrueif 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, ornullif this variant doesn't have a tag.Note: Use
nbtMatches(net.minecraft.nbt.NbtCompound)if you only need to check for custom tag equality, orgetNbt()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 staticfromNbt.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 staticfromPacket.Implementation note: Objects are saved using their raw registry integer id.
-