Class NBTHelper

java.lang.Object
com.petrolpark.util.NBTHelper

public class NBTHelper extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    equalIgnoring(net.minecraft.nbt.CompoundTag tag1, net.minecraft.nbt.CompoundTag tag2, String... ignoredKeys)
     
    static int
    readBogglePattern(net.minecraft.nbt.CompoundTag tag, String key)
     
    static <T> List<T>
    readCompoundList(net.minecraft.nbt.ListTag tag, Function<net.minecraft.nbt.CompoundTag,T> reader)
     
    static <OBJECT> OBJECT
    readDataRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> dataRegistryKey)
    Read a datapack-sensitive registered object.
    static <E extends Enum<E>>
    E
    readEnum(net.minecraft.nbt.CompoundTag tag, String key, Class<E> enumClass)
     
    static <OBJECT> OBJECT
    readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey)
    Read a global (non-datapack sensitive) registered object.
    static <OBJECT> OBJECT
    readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.core.RegistryAccess registryAccess)
    Read a registered object (datapack or global).
    static <OBJECT> OBJECT
    readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.world.level.Level level)
    Read a registered object (datapack or global).
    static net.minecraft.world.phys.Vec3
    readVec3(net.minecraft.nbt.ListTag tag, net.minecraft.core.BlockPos origin)
     
     
    static Consumer<net.minecraft.nbt.Tag>
    writeAt(net.minecraft.nbt.CompoundTag tag, String key)
     
    static void
    writeBogglePattern(net.minecraft.nbt.CompoundTag tag, String key, int binaryMatrix)
     
    static <T> net.minecraft.nbt.ListTag
    writeCompoundList(List<T> list, Function<T,net.minecraft.nbt.CompoundTag> writer)
     
    static <OBJECT> void
    writeDataRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> dataRegistryKey, OBJECT dataObject)
    Write a datapack-sensitive registered object.
    static <E extends Enum<E>>
    void
    writeEnum(net.minecraft.nbt.CompoundTag tag, String key, E enumValue)
     
    static <OBJECT> void
    writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.core.RegistryAccess registryAccess, OBJECT object)
    Write a registered object (datapack or global).
    static <OBJECT> void
    writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.world.level.Level level, OBJECT object)
    Write a registered object (datapack or global).
    static <OBJECT> void
    writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, OBJECT object)
    Write a global (non-datapack sensitive) registered object.
    static net.minecraft.nbt.ListTag
    writeVec3(net.minecraft.world.phys.Vec3 vec, net.minecraft.core.BlockPos origin)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NBTHelper

      public NBTHelper()
  • Method Details

    • equalIgnoring

      public static boolean equalIgnoring(net.minecraft.nbt.CompoundTag tag1, net.minecraft.nbt.CompoundTag tag2, String... ignoredKeys)
    • writeAt

      public static Consumer<net.minecraft.nbt.Tag> writeAt(net.minecraft.nbt.CompoundTag tag, String key)
    • readCompoundList

      public static <T> List<T> readCompoundList(net.minecraft.nbt.ListTag tag, Function<net.minecraft.nbt.CompoundTag,T> reader)
    • writeCompoundList

      public static <T> net.minecraft.nbt.ListTag writeCompoundList(List<T> list, Function<T,net.minecraft.nbt.CompoundTag> writer)
    • readEnum

      public static <E extends Enum<E>> E readEnum(net.minecraft.nbt.CompoundTag tag, String key, Class<E> enumClass)
    • writeEnum

      public static <E extends Enum<E>> void writeEnum(net.minecraft.nbt.CompoundTag tag, String key, E enumValue)
    • readVec3

      public static net.minecraft.world.phys.Vec3 readVec3(net.minecraft.nbt.ListTag tag, net.minecraft.core.BlockPos origin)
    • writeVec3

      public static net.minecraft.nbt.ListTag writeVec3(net.minecraft.world.phys.Vec3 vec, net.minecraft.core.BlockPos origin)
    • readBogglePattern

      public static int readBogglePattern(net.minecraft.nbt.CompoundTag tag, String key)
    • writeBogglePattern

      public static void writeBogglePattern(net.minecraft.nbt.CompoundTag tag, String key, int binaryMatrix)
    • readRegistryObject

      public static <OBJECT> OBJECT readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.world.level.Level level)
      Read a registered object (datapack or global).
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      level -
      Returns:
      null if the ResourceLocation is invalid
    • writeRegistryObject

      public static <OBJECT> void writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.world.level.Level level, OBJECT object)
      Write a registered object (datapack or global).
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      level -
      object -
    • readRegistryObject

      public static <OBJECT> OBJECT readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.core.RegistryAccess registryAccess)
      Read a registered object (datapack or global).
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      registryAccess -
      Returns:
      null if the ResourceLocation is invalid
    • writeRegistryObject

      public static <OBJECT> void writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, net.minecraft.core.RegistryAccess registryAccess, OBJECT object)
      Write a registered object (datapack or global).
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      registryAccess -
      object -
    • readRegistryObject

      public static <OBJECT> OBJECT readRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey)
      Read a global (non-datapack sensitive) registered object.
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      Returns:
      null if the ResourceLocation is invalid
    • writeRegistryObject

      public static <OBJECT> void writeRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> registryKey, OBJECT object)
      Write a global (non-datapack sensitive) registered object.
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      registryKey -
      object -
    • readDataRegistryObject

      public static <OBJECT> OBJECT readDataRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> dataRegistryKey)
      Read a datapack-sensitive registered object.
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      dataRegistryKey -
      Returns:
      null if the ResourceLocation is invalid
    • writeDataRegistryObject

      public static <OBJECT> void writeDataRegistryObject(net.minecraft.nbt.CompoundTag tag, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<OBJECT>> dataRegistryKey, OBJECT dataObject)
      Write a datapack-sensitive registered object.
      Type Parameters:
      OBJECT - Class of the object/registry
      Parameters:
      tag -
      key -
      dataRegistryKey -
      dataObject -
    • registryNotLoadedException

      public static IllegalStateException registryNotLoadedException()