Class ItemDataFix

java.lang.Object
com.saicone.rtag.item.ItemDataFix
Direct Known Subclasses:
ItemDataFix.MojangDataFix, ItemDataFix.RtagDataFix, ItemDataFix.SafeDataFix

@Experimental public abstract class ItemDataFix extends Object
This class provides a way to decode and encode items from/to NBT compounds, as well as update them between different Minecraft versions.
  • Constructor Details

    • ItemDataFix

      public ItemDataFix()
  • Method Details

    • mojang

      @NotNull public static @NotNull ItemDataFix mojang()
      Returns the Mojang implementation of the item data fix,
      Returns:
      an item data fix
    • rtag

      @NotNull public static @NotNull ItemDataFix rtag()
      Returns the Rtag implementation of the item data fix,
      Returns:
      an item data fix
    • safe

      @NotNull public static @NotNull ItemDataFix safe()
      Returns the safe implementation of the item data fix,
      Returns:
      an item data fix
    • decodeItem

      @NotNull public @NotNull ItemStack decodeItem(@Nullable @Nullable Object compound)
      Decodes an item from a NBT compound, updating it to the current Minecraft version if necessary.
      Parameters:
      compound - the NBT compound representing the item
      Returns:
      the decoded ItemStack
    • decodeItem

      @NotNull public @NotNull ItemStack decodeItem(@NotNull @NotNull Object compound, @NotNull @NotNull MC version)
      Decodes an item from a NBT compound, updating it to the current Minecraft version if necessary.
      Parameters:
      compound - the NBT compound representing the item
      version - the Minecraft version of the item
      Returns:
      the decoded ItemStack
    • decodeContainer

      @Nullable public @Nullable ItemStack[] decodeContainer(@Nullable @Nullable Object compound)
      Decodes an array of items from a NBT compound, updating them to the current Minecraft version if necessary.
      Parameters:
      compound - the NBT compound representing the container
      Returns:
      an array of decoded ItemStacks
    • encodeItem

      Encodes an item into a NBT compound.
      Parameters:
      item - the item to encode
      Returns:
      an encoded NBT compound
    • encodeItem

      @NotNull public @NotNull Object encodeItem(@Nullable @Nullable ItemStack item, @NotNull @NotNull MC version)
      Encodes an item into a NBT compound, adding the data version of the specified Minecraft version.
      Parameters:
      item - the item to encode
      version - the Minecraft version to use for the data version
      Returns:
      an encoded NBT compound
    • encodeContainer

      @NotNull public @NotNull Object encodeContainer(@Nullable @Nullable ItemStack[] items)
      Encodes an array of items into a NBT compound.
      Parameters:
      items - the array of items to encode
      Returns:
      an encoded NBT compound
    • encodeContainer

      @NotNull public @NotNull Object encodeContainer(@Nullable @Nullable ItemStack[] items, @NotNull @NotNull MC version)
      Encodes an array of items into a NBT compound, adding the data version of the specified Minecraft version.
      Parameters:
      items - the array of items to encode
      version - the Minecraft version to use for the data version
      Returns:
      an encoded NBT compound
    • updateItem

      @NotNull public abstract @NotNull Object updateItem(@NotNull @NotNull Object compound, @NotNull @NotNull MC version, @NotNull @NotNull MC newVersion)
      Updates an item NBT compound from one Minecraft version to another.
      Parameters:
      compound - the NBT compound representing the item
      version - the current Minecraft version of the item
      newVersion - the target Minecraft version to update the item to
      Returns:
      the updated NBT compound