Class Tag_Compound
java.lang.Object
de.pauleff.jnbt.core.Tag<ArrayList<Tag<?>>>
de.pauleff.jnbt.core.Collection_Tag
de.pauleff.jnbt.core.Tag_Compound
- All Implemented Interfaces:
ICompoundTag, ITag<ArrayList<Tag<?>>>
Represents an NBT compound tag - a named collection of heterogeneous tags
that forms the backbone of NBT data structures.
Compound tags store multiple child tags of different types, accessed by name. They provide both direct tag manipulation and fluent builder methods for common data types.
Extends Collection_Tag with compound-specific operations and
implements ICompoundTag for standardized access.
- Author:
- Paul Ferlitz
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty compound tag with default name.Tag_Compound(String name) Creates an empty compound tag with the specified name.Tag_Compound(String name, ArrayList<Tag<?>> data) Creates a compound tag pre-populated with child tags. -
Method Summary
Modifier and TypeMethodDescriptionAdds a byte tag and returns this compound for method chaining.addByteArray(String name, byte[] value) Adds a byte array tag and returns this compound for method chaining.Adds a double-precision tag and returns this compound for method chaining.Adds a single-precision float tag and returns this compound for method chaining.Adds an integer tag and returns this compound for method chaining.addIntArray(String name, int[] value) Adds an integer array tag and returns this compound for method chaining.Adds a long integer tag and returns this compound for method chaining.addLongArray(String name, long[] value) Adds a long array tag and returns this compound for method chaining.Adds a short integer tag and returns this compound for method chaining.Adds a string tag and returns this compound for method chaining.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.toString()Generates a hierarchical string representation showing all nested tags.Methods inherited from class Collection_Tag
addAllTags, addTag, getAllTags, getAllTagsByName, getTag, getTagByName, removeAllTags, removeAllTagsByName, removeTag, removeTagByName
-
Constructor Details
-
Tag_Compound
public Tag_Compound()Creates an empty compound tag with default name. -
Tag_Compound
Creates an empty compound tag with the specified name.- Parameters:
name- the tag name
-
Tag_Compound
-
-
Method Details
-
addString
Adds a string tag and returns this compound for method chaining.- Specified by:
addStringin interfaceICompoundTag- Parameters:
name- the tag namevalue- the string value- Returns:
- this compound tag for fluent operations
- See Also:
-
addInt
Adds an integer tag and returns this compound for method chaining.- Specified by:
addIntin interfaceICompoundTag- Parameters:
name- the tag namevalue- the integer value- Returns:
- this compound tag for fluent operations
- See Also:
-
addDouble
Adds a double-precision tag and returns this compound for method chaining.- Specified by:
addDoublein interfaceICompoundTag- Parameters:
name- the tag namevalue- the double value- Returns:
- this compound tag for fluent operations
- See Also:
-
addFloat
Adds a single-precision float tag and returns this compound for method chaining.- Specified by:
addFloatin interfaceICompoundTag- Parameters:
name- the tag namevalue- the float value- Returns:
- this compound tag for fluent operations
- See Also:
-
addByte
Adds a byte tag and returns this compound for method chaining.- Specified by:
addBytein interfaceICompoundTag- Parameters:
name- the tag namevalue- the byte value- Returns:
- this compound tag for fluent operations
- See Also:
-
addShort
Adds a short integer tag and returns this compound for method chaining.- Specified by:
addShortin interfaceICompoundTag- Parameters:
name- the tag namevalue- the short value- Returns:
- this compound tag for fluent operations
- See Also:
-
addLong
Adds a long integer tag and returns this compound for method chaining.- Specified by:
addLongin interfaceICompoundTag- Parameters:
name- the tag namevalue- the long value- Returns:
- this compound tag for fluent operations
- See Also:
-
addByteArray
Adds a byte array tag and returns this compound for method chaining.- Specified by:
addByteArrayin interfaceICompoundTag- Parameters:
name- the tag namevalue- the byte array value- Returns:
- this compound tag for fluent operations
- See Also:
-
addIntArray
Adds an integer array tag and returns this compound for method chaining.- Specified by:
addIntArrayin interfaceICompoundTag- Parameters:
name- the tag namevalue- the integer array value- Returns:
- this compound tag for fluent operations
- See Also:
-
addLongArray
Adds a long array tag and returns this compound for method chaining.- Specified by:
addLongArrayin interfaceICompoundTag- Parameters:
name- the tag namevalue- the long array value- Returns:
- this compound tag for fluent operations
- See Also:
-
hasTag
Description copied from interface:ICompoundTagChecks whether this compound contains a tag with the specified name.- Specified by:
hasTagin interfaceICompoundTag- Parameters:
tagName- The name to search for- Returns:
trueif a tag with this name exists,falseotherwise
-
getTag
Description copied from interface:ICompoundTagRetrieves a child tag by name without requiring casts.- Specified by:
getTagin interfaceICompoundTag- Parameters:
name- The name of the tag to find- Returns:
- The tag if found,
nullotherwise
-
getString
Description copied from interface:ICompoundTagRetrieves a string value directly from a child tag.- Specified by:
getStringin interfaceICompoundTag- Parameters:
name- The name of the string tag- Returns:
- The string value, or
nullif tag doesn't exist or isn't a string
-
getInt
Description copied from interface:ICompoundTagRetrieves an integer value directly from a child tag.- Specified by:
getIntin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a double value directly from a child tag.- Specified by:
getDoublein interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a byte value directly from a child tag.- Specified by:
getBytein interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a float value directly from a child tag.- Specified by:
getFloatin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a short value directly from a child tag.- Specified by:
getShortin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a long value directly from a child tag.- Specified by:
getLongin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a compound tag by name without casting.- Specified by:
getCompoundin interfaceICompoundTag- Parameters:
name- The name of the compound tag- Returns:
- The
ICompoundTagif found,nullotherwise
-
getList
Description copied from interface:ICompoundTagRetrieves a list tag by name without casting.- Specified by:
getListin interfaceICompoundTag- Parameters:
name- The name of the list tag- Returns:
- The
IListTagif found,nullotherwise
-
getByteArray
Description copied from interface:ICompoundTagRetrieves a byte array value directly from a child tag.- Specified by:
getByteArrayin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves an integer array value directly from a child tag.- Specified by:
getIntArrayin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagRetrieves a long array value directly from a child tag.- Specified by:
getLongArrayin interfaceICompoundTag- 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
Description copied from interface:ICompoundTagUpdates or creates a string tag with the given name and value.- Specified by:
setStringin interfaceICompoundTag- Parameters:
name- The tag namevalue- TheStringvalue to store- Returns:
- This compound for fluent method chaining
-
setInt
Description copied from interface:ICompoundTagUpdates or creates an integer tag with the given name and value.- Specified by:
setIntin interfaceICompoundTag- Parameters:
name- The tag namevalue- TheIntegervalue to store- Returns:
- This compound for fluent method chaining
-
setDouble
Description copied from interface:ICompoundTagUpdates or creates a double-precision floating point tag.- Specified by:
setDoublein interfaceICompoundTag- Parameters:
name- The tag namevalue- TheDoublevalue to store- Returns:
- This compound for fluent method chaining
-
setFloat
Description copied from interface:ICompoundTagUpdates or creates a single-precision floating point tag.- Specified by:
setFloatin interfaceICompoundTag- Parameters:
name- The tag namevalue- TheFloatvalue to store- Returns:
- This compound for fluent method chaining
-
setByte
Description copied from interface:ICompoundTagUpdates or creates a byte tag with the given name and value.- Specified by:
setBytein interfaceICompoundTag- Parameters:
name- The tag namevalue- TheBytevalue to store- Returns:
- This compound for fluent method chaining
-
setShort
Description copied from interface:ICompoundTagUpdates or creates a short integer tag.- Specified by:
setShortin interfaceICompoundTag- Parameters:
name- The tag namevalue- TheShortvalue to store- Returns:
- This compound for fluent method chaining
-
setLong
Description copied from interface:ICompoundTagUpdates or creates a long integer tag.- Specified by:
setLongin interfaceICompoundTag- Parameters:
name- The tag namevalue- TheLongvalue to store- Returns:
- This compound for fluent method chaining
-
setByteArray
Description copied from interface:ICompoundTagUpdates or creates a byte array tag.- Specified by:
setByteArrayin interfaceICompoundTag- Parameters:
name- The tag namevalue- The byte array value to store- Returns:
- This compound for fluent method chaining
-
setIntArray
Description copied from interface:ICompoundTagUpdates or creates an integer array tag.- Specified by:
setIntArrayin interfaceICompoundTag- Parameters:
name- The tag namevalue- The integer array value to store- Returns:
- This compound for fluent method chaining
-
setLongArray
Description copied from interface:ICompoundTagUpdates or creates a long array tag.- Specified by:
setLongArrayin interfaceICompoundTag- Parameters:
name- The tag namevalue- The long array value to store- Returns:
- This compound for fluent method chaining
-
setTag
Description copied from interface:ICompoundTagUpdates or replaces an existing tag with a new one.- Specified by:
setTagin interfaceICompoundTag- Parameters:
tag- The tag to set (replaces any existing tag with the same name)- Returns:
- This compound for fluent method chaining
-
removeTag
Description copied from interface:ICompoundTagRemoves a tag by name and returns this compound for chaining.- Specified by:
removeTagin interfaceICompoundTag- Parameters:
name- The name of the tag to remove- Returns:
- This compound for fluent method chaining
-
removeTags
Description copied from interface:ICompoundTagRemoves multiple tags by name and returns this compound for chaining.- Specified by:
removeTagsin interfaceICompoundTag- Parameters:
names- The names of the tags to remove- Returns:
- This compound for fluent method chaining
-
clear
Description copied from interface:ICompoundTagRemoves all tags from this compound.- Specified by:
clearin interfaceICompoundTag- Returns:
- This compound for fluent method chaining
-
size
public int size()Description copied from interface:ICompoundTagGets the number of child tags in this compound.- Specified by:
sizein interfaceICompoundTag- Returns:
- The number of child tags
-
isEmpty
public boolean isEmpty()Description copied from interface:ICompoundTagChecks if this compound is empty (has no child tags).- Specified by:
isEmptyin interfaceICompoundTag- Returns:
trueif empty,falseotherwise
-
toString
Generates a hierarchical string representation showing all nested tags.Output includes tag type, name, size, and recursively formatted child tags.
-