Class NbtX

java.lang.Object
org.moddingx.libx.util.data.NbtX

public class NbtX extends Object
Utilities to deal with NBT.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.resources.ResourceLocation
    getResource(net.minecraft.nbt.CompoundTag nbt, String key)
    Gets a ResourceLocation from a CompoundTag stored with a given key or null if there's no such resource location.
    static net.minecraft.resources.ResourceLocation
    getResource(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceLocation defaultValue)
    Gets a ResourceLocation from a CompoundTag stored with a given key or the default value if there's no such resource location.
    static <T> net.minecraft.resources.ResourceKey<T>
    getResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry)
    Gets a ResourceKey.
    static <T> net.minecraft.resources.ResourceKey<T>
    getResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, net.minecraft.resources.ResourceKey<T> defaultValue)
    Gets a ResourceKey.
    static void
    putResource(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceLocation rl)
    Stores a ResourceLocation in a CompoundTag with a given key.
    static void
    putResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<?> rl)
    Stores the location of a ResourceKey.

    Methods inherited from class java.lang.Object

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

    • NbtX

      public NbtX()
  • Method Details

    • putResource

      public static void putResource(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceLocation rl)
      Stores a ResourceLocation in a CompoundTag with a given key.
    • getResource

      @Nullable public static net.minecraft.resources.ResourceLocation getResource(net.minecraft.nbt.CompoundTag nbt, String key)
      Gets a ResourceLocation from a CompoundTag stored with a given key or null if there's no such resource location.
    • getResource

      public static net.minecraft.resources.ResourceLocation getResource(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceLocation defaultValue)
      Gets a ResourceLocation from a CompoundTag stored with a given key or the default value if there's no such resource location.
    • putResourceKey

      public static void putResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<?> rl)
      Stores the location of a ResourceKey. This will not store the registry.
      See Also:
    • getResourceKey

      @Nullable public static <T> net.minecraft.resources.ResourceKey<T> getResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry)
      Gets a ResourceKey. This will only load the location, the Registry must be provided by the caller.
      See Also:
    • getResourceKey

      public static <T> net.minecraft.resources.ResourceKey<T> getResourceKey(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<net.minecraft.core.Registry<T>> registry, net.minecraft.resources.ResourceKey<T> defaultValue)
      Gets a ResourceKey. This will only load the location, the Registry must be provided by the caller.
      See Also: