Package org.moddingx.libx.util.data
Class NbtX
java.lang.Object
org.moddingx.libx.util.data.NbtX
Utilities to deal with NBT.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.resources.ResourceLocation
getResource
(net.minecraft.nbt.CompoundTag nbt, String key) Gets aResourceLocation
from aCompoundTag
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 aResourceLocation
from aCompoundTag
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 aResourceKey
.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 aResourceKey
.static void
putResource
(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceLocation rl) Stores aResourceLocation
in aCompoundTag
with a given key.static void
putResourceKey
(net.minecraft.nbt.CompoundTag nbt, String key, net.minecraft.resources.ResourceKey<?> rl) Stores the location of aResourceKey
.
-
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 aResourceLocation
in aCompoundTag
with a given key. -
getResource
@Nullable public static net.minecraft.resources.ResourceLocation getResource(net.minecraft.nbt.CompoundTag nbt, String key) Gets aResourceLocation
from aCompoundTag
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 aResourceLocation
from aCompoundTag
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 aResourceKey
. This will not store the registry. -
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 aResourceKey
. This will only load the location, theRegistry
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 aResourceKey
. This will only load the location, theRegistry
must be provided by the caller.
-