Package etithespirit.orimod.util.nbt
Class NBTIOHelper
java.lang.Object
etithespirit.orimod.util.nbt.NBTIOHelper
This class provides utilities that allow writing some more object types to NBT as well as reading that data back.
-
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.world.level.ChunkPos
getChunkPos
(net.minecraft.nbt.CompoundTag from, String name) Reads aChunkPos
from the given tag.static net.minecraft.world.level.ChunkPos[]
getManyChunkPos
(net.minecraft.nbt.CompoundTag from, String name) Reads manyChunkPos
instances from the given tag under the given name.static net.minecraft.core.Vec3i
getVector3i
(net.minecraft.nbt.CompoundTag from, String name) Reads aVec3i
from the given tag.static void
putChunkPos
(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos location) Writes the givenChunkPos
to the given tag.static void
putManyChunkPos
(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos... locations) Writes manyChunkPos
instances to the given tag under the given name.static void
putVector3i
(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.core.Vec3i vector) Writes the given Vector to the given tag.
-
Method Details
-
putVector3i
public static void putVector3i(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.core.Vec3i vector) Writes the given Vector to the given tag.- Parameters:
to
- The tag to write to.name
- The name of the value to write.vector
- The actual value being written.
-
getVector3i
Reads aVec3i
from the given tag.- Parameters:
from
- The tag to read from.name
- The name of the value to read.- Returns:
- The acquired
Vec3i
. - Throws:
IllegalArgumentException
- if the associated value is not an integer array with 3 elements in it, including if the value is missing.
-
putChunkPos
public static void putChunkPos(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos location) Writes the givenChunkPos
to the given tag.- Parameters:
to
- The tag to write to.name
- The name of the value to write.location
- The actual value being written.
-
getChunkPos
public static net.minecraft.world.level.ChunkPos getChunkPos(net.minecraft.nbt.CompoundTag from, String name) Reads aChunkPos
from the given tag.- Parameters:
from
- The tag to read from.name
- The name of the value to read.- Returns:
- The acquired
ChunkPos
. - Throws:
IllegalArgumentException
- if the associated value is not an integer array with 2 elements in it, including if the value is missing.
-
putManyChunkPos
public static void putManyChunkPos(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos... locations) Writes manyChunkPos
instances to the given tag under the given name.- Parameters:
to
- The tag to write to.name
- The name to associate the values with.locations
- The actual values being written.- Throws:
NullPointerException
- If any location is null.
-
getManyChunkPos
public static net.minecraft.world.level.ChunkPos[] getManyChunkPos(net.minecraft.nbt.CompoundTag from, String name) Reads manyChunkPos
instances from the given tag under the given name.- Parameters:
from
- The tag to read from.name
- The name of the array storing the values.- Returns:
- An array of the retrieved
ChunkPos
instances. - Throws:
IllegalArgumentException
- if the associated value is not an integer array with an even number of elements in it (eachChunkPos
) must write two integers). If there are 0 elements, this returns an empty array.
-