Class NBTIOHelper

java.lang.Object
etithespirit.orimod.util.nbt.NBTIOHelper

public final class NBTIOHelper extends Object
This class provides utilities that allow writing some more object types to NBT as well as reading that data back.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.minecraft.world.level.ChunkPos
    getChunkPos(net.minecraft.nbt.CompoundTag from, String name)
    Reads a ChunkPos from the given tag.
    static net.minecraft.world.level.ChunkPos[]
    getManyChunkPos(net.minecraft.nbt.CompoundTag from, String name)
    Reads many ChunkPos instances from the given tag under the given name.
    static net.minecraft.core.Vec3i
    getVector3i(net.minecraft.nbt.CompoundTag from, String name)
    Reads a Vec3i from the given tag.
    static void
    putChunkPos(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos location)
    Writes the given ChunkPos to the given tag.
    static void
    putManyChunkPos(net.minecraft.nbt.CompoundTag to, String name, net.minecraft.world.level.ChunkPos... locations)
    Writes many ChunkPos 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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static net.minecraft.core.Vec3i getVector3i(net.minecraft.nbt.CompoundTag from, String name)
      Reads a Vec3i 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 given ChunkPos 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 a ChunkPos 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 many ChunkPos 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 many ChunkPos 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 (each ChunkPos) must write two integers). If there are 0 elements, this returns an empty array.