Class Tag_List
Represents an NBT list tag - a homogeneous collection containing multiple
tags of the same type, accessed by index rather than name.
List tags enforce type consistency, ensuring all contained elements match the declared list type. They provide indexed access and fluent builder methods for type-safe element addition.
Extends Collection_Tag with list-specific type validation and
implements IListTag for standardized access.
- Author:
- Paul Ferlitz
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTag_List(int listTypeID) Creates an empty list with the specified element type.Creates an empty named list with the specified element type.Creates a list pre-populated with elements of the specified type. -
Method Summary
Modifier and TypeMethodDescriptionaddCompound(String name) Adds a compound element to this list with fluent chaining.Adds a double-precision element to this list with fluent chaining.Adds an integer element to this list with fluent chaining.Adds a string element to this list with fluent chaining.intReturns the NBT type identifier for elements in this list.toString()Generates a hierarchical string representation showing list metadata and elements.Methods inherited from class de.pauleff.core.Collection_Tag
addAllTags, addTag, getAllTags, getAllTagsByName, getTag, getTagByName, removeAllTags, removeAllTagsByName, removeTag, removeTagByNameMethods inherited from class de.pauleff.core.Tag
applyOperation, editTag, equals, getData, getId, getName, hashCode, setData, setName
-
Constructor Details
-
Tag_List
public Tag_List(int listTypeID) Creates an empty list with the specified element type.- Parameters:
listTypeID- the NBT type ID for all elements in this list
-
Tag_List
Creates an empty named list with the specified element type.- Parameters:
name- the tag namelistTypeID- the NBT type ID for all elements in this list
-
Tag_List
-
-
Method Details
-
getListTypeID
public int getListTypeID()Returns the NBT type identifier for elements in this list.All elements must match this type to maintain list homogeneity.
- Specified by:
getListTypeIDin interfaceIListTag- Returns:
- the NBT type ID of list elements
-
addString
Adds a string element to this list with fluent chaining.Only valid for lists declared as string type.
- Specified by:
addStringin interfaceIListTag- Parameters:
name- the element namevalue- the string value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_String- See Also:
-
addInt
Adds an integer element to this list with fluent chaining.Only valid for lists declared as integer type.
- Specified by:
addIntin interfaceIListTag- Parameters:
name- the element namevalue- the integer value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Int- See Also:
-
addDouble
Adds a double-precision element to this list with fluent chaining.Only valid for lists declared as double type.
- Specified by:
addDoublein interfaceIListTag- Parameters:
name- the element namevalue- the double value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Double- See Also:
-
addCompound
Adds a compound element to this list with fluent chaining.Only valid for lists declared as compound type.
- Specified by:
addCompoundin interfaceIListTag- Parameters:
name- the element name- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Compound- See Also:
-
toString
Generates a hierarchical string representation showing list metadata and elements.Output includes tag type, name, element type, size, and formatted child elements.
-