Interface ICompoundTag
- All Known Implementing Classes:
Tag_Compound
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 Summary
Modifier and TypeMethodDescriptionAdds a byte tag with the given name and value.addByteArray(String name, byte[] value) Adds a byte array tag.Adds a double-precision floating point tag.Adds a single-precision floating point tag.Adds an integer tag with the given name and value.addIntArray(String name, int[] value) Adds an integer array tag.Adds a long integer tag.addLongArray(String name, long[] value) Adds a long array tag.Adds a short integer tag.Adds a string tag with the given name and value.clear()Removes all tags from this compound.byteRetrieves a byte value directly from a child tag.byte[]getByteArray(String name) Retrieves a byte array value directly from a child tag.getCompound(String name) Retrieves a compound tag by name without casting.doubleRetrieves a double value directly from a child tag.floatRetrieves a float value directly from a child tag.intRetrieves an integer value directly from a child tag.int[]getIntArray(String name) Retrieves an integer array value directly from a child tag.Retrieves a list tag by name without casting.longRetrieves a long value directly from a child tag.long[]getLongArray(String name) Retrieves a long array value directly from a child tag.shortRetrieves a short value directly from a child tag.Retrieves a string value directly from a child tag.ITag<?> Retrieves a child tag by name without requiring casts.booleanChecks whether this compound contains a tag with the specified name.booleanisEmpty()Checks if this compound is empty (has no child tags).Removes a tag by name and returns this compound for chaining.removeTags(String... names) Removes multiple tags by name and returns this compound for chaining.Updates or creates a byte tag with the given name and value.setByteArray(String name, byte[] value) Updates or creates a byte array tag.Updates or creates a double-precision floating point tag.Updates or creates a single-precision floating point tag.Updates or creates an integer tag with the given name and value.setIntArray(String name, int[] value) Updates or creates an integer array tag.Updates or creates a long integer tag.setLongArray(String name, long[] value) Updates or creates a long array tag.Updates or creates a short integer tag.Updates or creates a string tag with the given name and value.Updates or replaces an existing tag with a new one.intsize()Gets the number of child tags in this compound.
-
Method Details
-
hasTag
Checks whether this compound contains a tag with the specified name.- Parameters:
tagName- The name to search for- Returns:
trueif a tag with this name exists,falseotherwise
-
addString
Adds a string tag with the given name and value.- Parameters:
name- The tag namevalue- TheStringvalue to store- Returns:
- This compound for fluent method chaining
-
addInt
Adds an integer tag with the given name and value.- Parameters:
name- The tag namevalue- TheIntegervalue to store- Returns:
- This compound for fluent method chaining
-
addDouble
Adds a double-precision floating point tag.- Parameters:
name- The tag namevalue- TheDoublevalue to store- Returns:
- This compound for fluent method chaining
-
addFloat
Adds a single-precision floating point tag.- Parameters:
name- The tag namevalue- TheFloatvalue to store- Returns:
- This compound for fluent method chaining
-
addByte
Adds a byte tag with the given name and value.- Parameters:
name- The tag namevalue- TheBytevalue to store- Returns:
- This compound for fluent method chaining
-
addShort
Adds a short integer tag.- Parameters:
name- The tag namevalue- TheShortvalue to store- Returns:
- This compound for fluent method chaining
-
addLong
Adds a long integer tag.- Parameters:
name- The tag namevalue- TheLongvalue to store- Returns:
- This compound for fluent method chaining
-
addByteArray
Adds a byte array tag.- Parameters:
name- The tag namevalue- The byte array value to store- Returns:
- This compound for fluent method chaining
-
addIntArray
Adds an integer array tag.- Parameters:
name- The tag namevalue- The integer array value to store- Returns:
- This compound for fluent method chaining
-
addLongArray
Adds a long array tag.- Parameters:
name- The tag namevalue- The long array value to store- Returns:
- This compound for fluent method chaining
-
getTag
-
getString
-
getInt
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
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
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
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
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
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
Retrieves a compound tag by name without casting.- Parameters:
name- The name of the compound tag- Returns:
- The
ICompoundTagif found,nullotherwise
-
getList
-
getByteArray
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
nullif tag doesn't exist or isn't a byte array
-
getIntArray
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
nullif tag doesn't exist or isn't an integer array
-
getLongArray
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
nullif tag doesn't exist or isn't a long array
-
setString
Updates or creates a string tag with the given name and value.- Parameters:
name- The tag namevalue- TheStringvalue to store- Returns:
- This compound for fluent method chaining
-
setInt
Updates or creates an integer tag with the given name and value.- Parameters:
name- The tag namevalue- TheIntegervalue to store- Returns:
- This compound for fluent method chaining
-
setDouble
Updates or creates a double-precision floating point tag.- Parameters:
name- The tag namevalue- TheDoublevalue to store- Returns:
- This compound for fluent method chaining
-
setFloat
Updates or creates a single-precision floating point tag.- Parameters:
name- The tag namevalue- TheFloatvalue to store- Returns:
- This compound for fluent method chaining
-
setByte
Updates or creates a byte tag with the given name and value.- Parameters:
name- The tag namevalue- TheBytevalue to store- Returns:
- This compound for fluent method chaining
-
setShort
Updates or creates a short integer tag.- Parameters:
name- The tag namevalue- TheShortvalue to store- Returns:
- This compound for fluent method chaining
-
setLong
Updates or creates a long integer tag.- Parameters:
name- The tag namevalue- TheLongvalue to store- Returns:
- This compound for fluent method chaining
-
setByteArray
Updates or creates a byte array tag.- Parameters:
name- The tag namevalue- The byte array value to store- Returns:
- This compound for fluent method chaining
-
setIntArray
Updates or creates an integer array tag.- Parameters:
name- The tag namevalue- The integer array value to store- Returns:
- This compound for fluent method chaining
-
setLongArray
Updates or creates a long array tag.- Parameters:
name- The tag namevalue- The long array value to store- Returns:
- This compound for fluent method chaining
-
setTag
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
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
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:
trueif empty,falseotherwise
-