Class NBTCompound

java.lang.Object
org.mattrick.enbeet.NBTCompound

public class NBTCompound extends Object
A Minecraft NBT Compound.
  • Constructor Details

    • NBTCompound

      public NBTCompound()
      Create a new NBTCompound.
    • NBTCompound

      public NBTCompound(String name)
      Create a new NBTCompound with the given name in its root.
  • Method Details

    • getName

      public Optional<String> getName()
      Get the name of this NBTCompound ("named tag"), if it exists.
      Returns:
      An Optional, containing the name of this tag if it exists.
    • setName

      public void setName(String name)
      Set the name of this NBTCompound ("named tag").
      Parameters:
      name - Set the name of this NBTCompound.
    • set

      public void set(Object value, String... path)
      Set a value in the NBTCompound.
      Parameters:
      value - The value to set.
      path - The path to set to the value.
    • get

      public Optional<Object> get(String... path)
      Get the value at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the value at the path if it exists.
    • get

      public <T> Optional<T> get(Class<T> type, String... path)
      Get the value of the given type at the given path.
      Type Parameters:
      T - The type of the object at the path.
      Parameters:
      type - The type to get.
      path - The path to get.
      Returns:
      An Optional containing the value at the path if it exists and matches the provided type.
    • getByte

      public Optional<Byte> getByte(String... path)
      Get a Byte at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Byte at the path if it exists.
    • getShort

      public Optional<Short> getShort(String... path)
      Get a Short at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Short at the path if it exists.
    • getInt

      public Optional<Integer> getInt(String... path)
      Get a Integer at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Integer at the path if it exists.
    • getLong

      public Optional<Long> getLong(String... path)
      Get a Long at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Long at the path if it exists.
    • getFloat

      public Optional<Float> getFloat(String... path)
      Get a Float at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Float at the path if it exists.
    • getDouble

      public Optional<Double> getDouble(String... path)
      Get a Double at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the Double at the path if it exists.
    • getByteArray

      public Optional<byte[]> getByteArray(String... path)
      Get a byte[] at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the byte[] at the path if it exists.
    • getString

      public Optional<String> getString(String... path)
      Get a String at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the String at the path if it exists.
    • getList

      public Optional<NBTList> getList(String... path)
      Get a NBTList at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the NBTList at the path if it exists.
    • getCompound

      public Optional<NBTCompound> getCompound(String... path)
      Get a NBTCompound at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the NBTCompound at the path if it exists.
    • getIntArray

      public Optional<int[]> getIntArray(String... path)
      Get a int[] at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the int[] at the path if it exists.
    • getLongArray

      public Optional<long[]> getLongArray(String... path)
      Get a long[] at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the long[] at the path if it exists.
    • getVarIntArray

      public Optional<int[]> getVarIntArray(String... path)
      Get a int[] (which was coded as a varint array) at the given path.
      Parameters:
      path - The path to get.
      Returns:
      An Optional containing the varint array at the path if it exists.
    • data

      public Map<String,​Object> data()
      Get the backing Map of the NBTCompound.
      Returns:
      The backing Map.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object