Interface ICompoundTag

All Superinterfaces:
ITag<ArrayList<Tag<?>>>
All Known Implementing Classes:
Tag_Compound

public interface ICompoundTag extends ITag<ArrayList<Tag<?>>>
Interface for NBT compound tags - the workhorse of NBT data structures. Compounds function like dictionaries or maps, storing named child tags in key-value pairs. They're essential for organizing complex data like player inventories, world chunks, and entity properties.
Author:
Paul Ferlitz
See Also:
  • Method Details

    • hasTag

      boolean hasTag(String tagName)
      Checks whether this compound contains a tag with the specified name.
      Parameters:
      tagName - The name to search for
      Returns:
      true if a tag with this name exists, false otherwise
    • addString

      ICompoundTag addString(String name, String value)
      Adds a string tag with the given name and value.
      Parameters:
      name - The tag name
      value - The String value to store
      Returns:
      This compound for fluent method chaining
    • addInt

      ICompoundTag addInt(String name, int value)
      Adds an integer tag with the given name and value.
      Parameters:
      name - The tag name
      value - The Integer value to store
      Returns:
      This compound for fluent method chaining
    • addDouble

      ICompoundTag addDouble(String name, double value)
      Adds a double-precision floating point tag.
      Parameters:
      name - The tag name
      value - The Double value to store
      Returns:
      This compound for fluent method chaining
    • addFloat

      ICompoundTag addFloat(String name, float value)
      Adds a single-precision floating point tag.
      Parameters:
      name - The tag name
      value - The Float value to store
      Returns:
      This compound for fluent method chaining
    • addByte

      ICompoundTag addByte(String name, byte value)
      Adds a byte tag with the given name and value.
      Parameters:
      name - The tag name
      value - The Byte value to store
      Returns:
      This compound for fluent method chaining
    • addShort

      ICompoundTag addShort(String name, short value)
      Adds a short integer tag.
      Parameters:
      name - The tag name
      value - The Short value to store
      Returns:
      This compound for fluent method chaining
    • addLong

      ICompoundTag addLong(String name, long value)
      Adds a long integer tag.
      Parameters:
      name - The tag name
      value - The Long value to store
      Returns:
      This compound for fluent method chaining
    • addByteArray

      ICompoundTag addByteArray(String name, byte[] value)
      Adds a byte array tag.
      Parameters:
      name - The tag name
      value - The byte array value to store
      Returns:
      This compound for fluent method chaining
    • addIntArray

      ICompoundTag addIntArray(String name, int[] value)
      Adds an integer array tag.
      Parameters:
      name - The tag name
      value - The integer array value to store
      Returns:
      This compound for fluent method chaining
    • addLongArray

      ICompoundTag addLongArray(String name, long[] value)
      Adds a long array tag.
      Parameters:
      name - The tag name
      value - The long array value to store
      Returns:
      This compound for fluent method chaining
    • getTag

      ITag<?> getTag(String name)
      Retrieves a child tag by name without requiring casts.
      Parameters:
      name - The name of the tag to find
      Returns:
      The tag if found, null otherwise
    • getString

      String getString(String name)
      Retrieves a string value directly from a child tag.
      Parameters:
      name - The name of the string tag
      Returns:
      The string value, or null if tag doesn't exist or isn't a string
    • getInt

      int getInt(String name)
      Retrieves an integer value directly from a child tag.
      Parameters:
      name - The name of the integer tag
      Returns:
      The integer value, or 0 if tag doesn't exist or isn't an integer
    • getDouble

      double getDouble(String name)
      Retrieves a double value directly from a child tag.
      Parameters:
      name - The name of the double tag
      Returns:
      The double value, or 0.0 if tag doesn't exist or isn't a double
    • getByte

      byte getByte(String name)
      Retrieves a byte value directly from a child tag.
      Parameters:
      name - The name of the byte tag
      Returns:
      The byte value, or 0 if tag doesn't exist or isn't a byte
    • getFloat

      float getFloat(String name)
      Retrieves a float value directly from a child tag.
      Parameters:
      name - The name of the float tag
      Returns:
      The float value, or 0.0f if tag doesn't exist or isn't a float
    • getShort

      short getShort(String name)
      Retrieves a short value directly from a child tag.
      Parameters:
      name - The name of the short tag
      Returns:
      The short value, or 0 if tag doesn't exist or isn't a short
    • getLong

      long getLong(String name)
      Retrieves a long value directly from a child tag.
      Parameters:
      name - The name of the long tag
      Returns:
      The long value, or 0L if tag doesn't exist or isn't a long
    • getCompound

      ICompoundTag getCompound(String name)
      Retrieves a compound tag by name without casting.
      Parameters:
      name - The name of the compound tag
      Returns:
      The ICompoundTag if found, null otherwise
    • getList

      IListTag getList(String name)
      Retrieves a list tag by name without casting.
      Parameters:
      name - The name of the list tag
      Returns:
      The IListTag if found, null otherwise
    • getByteArray

      byte[] getByteArray(String name)
      Retrieves a byte array value directly from a child tag.
      Parameters:
      name - The name of the byte array tag
      Returns:
      The byte array value, or null if tag doesn't exist or isn't a byte array
    • getIntArray

      int[] getIntArray(String name)
      Retrieves an integer array value directly from a child tag.
      Parameters:
      name - The name of the integer array tag
      Returns:
      The integer array value, or null if tag doesn't exist or isn't an integer array
    • getLongArray

      long[] getLongArray(String name)
      Retrieves a long array value directly from a child tag.
      Parameters:
      name - The name of the long array tag
      Returns:
      The long array value, or null if tag doesn't exist or isn't a long array
    • setString

      ICompoundTag setString(String name, String value)
      Updates or creates a string tag with the given name and value.
      Parameters:
      name - The tag name
      value - The String value to store
      Returns:
      This compound for fluent method chaining
    • setInt

      ICompoundTag setInt(String name, int value)
      Updates or creates an integer tag with the given name and value.
      Parameters:
      name - The tag name
      value - The Integer value to store
      Returns:
      This compound for fluent method chaining
    • setDouble

      ICompoundTag setDouble(String name, double value)
      Updates or creates a double-precision floating point tag.
      Parameters:
      name - The tag name
      value - The Double value to store
      Returns:
      This compound for fluent method chaining
    • setFloat

      ICompoundTag setFloat(String name, float value)
      Updates or creates a single-precision floating point tag.
      Parameters:
      name - The tag name
      value - The Float value to store
      Returns:
      This compound for fluent method chaining
    • setByte

      ICompoundTag setByte(String name, byte value)
      Updates or creates a byte tag with the given name and value.
      Parameters:
      name - The tag name
      value - The Byte value to store
      Returns:
      This compound for fluent method chaining
    • setShort

      ICompoundTag setShort(String name, short value)
      Updates or creates a short integer tag.
      Parameters:
      name - The tag name
      value - The Short value to store
      Returns:
      This compound for fluent method chaining
    • setLong

      ICompoundTag setLong(String name, long value)
      Updates or creates a long integer tag.
      Parameters:
      name - The tag name
      value - The Long value to store
      Returns:
      This compound for fluent method chaining
    • setByteArray

      ICompoundTag setByteArray(String name, byte[] value)
      Updates or creates a byte array tag.
      Parameters:
      name - The tag name
      value - The byte array value to store
      Returns:
      This compound for fluent method chaining
    • setIntArray

      ICompoundTag setIntArray(String name, int[] value)
      Updates or creates an integer array tag.
      Parameters:
      name - The tag name
      value - The integer array value to store
      Returns:
      This compound for fluent method chaining
    • setLongArray

      ICompoundTag setLongArray(String name, long[] value)
      Updates or creates a long array tag.
      Parameters:
      name - The tag name
      value - The long array value to store
      Returns:
      This compound for fluent method chaining
    • setTag

      ICompoundTag setTag(ITag<?> tag)
      Updates or replaces an existing tag with a new one.
      Parameters:
      tag - The tag to set (replaces any existing tag with the same name)
      Returns:
      This compound for fluent method chaining
    • removeTag

      ICompoundTag removeTag(String name)
      Removes a tag by name and returns this compound for chaining.
      Parameters:
      name - The name of the tag to remove
      Returns:
      This compound for fluent method chaining
    • removeTags

      ICompoundTag removeTags(String... names)
      Removes multiple tags by name and returns this compound for chaining.
      Parameters:
      names - The names of the tags to remove
      Returns:
      This compound for fluent method chaining
    • clear

      ICompoundTag clear()
      Removes all tags from this compound.
      Returns:
      This compound for fluent method chaining
    • size

      int size()
      Gets the number of child tags in this compound.
      Returns:
      The number of child tags
    • isEmpty

      boolean isEmpty()
      Checks if this compound is empty (has no child tags).
      Returns:
      true if empty, false otherwise