Class Tag_List
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 TypeMethodDescriptionAdds a byte element to this list with fluent chaining.addCompound(String name) Adds a compound element to this list with fluent chaining.Adds a double-precision element to this list with fluent chaining.Adds a float element to this list with fluent chaining.Adds an integer element to this list with fluent chaining.Adds a long element to this list with fluent chaining.Adds a short element to this list with fluent chaining.Adds a string element to this list with fluent chaining.clear()Removes all elements from this list.ITag<?> get(int index) Gets the element at the specified index.intReturns the NBT type identifier for elements in this list.booleanisEmpty()Checks if this list is empty (has no elements).Removes the first element that matches the given tag.removeAt(int index) Removes an element at the specified index.Updates an element at the specified index with a new byte value.setCompound(int index, String name) Updates an element at the specified index with a new compound.Updates an element at the specified index with a new double value.Updates an element at the specified index with a new float value.Updates an element at the specified index with a new integer value.Updates an element at the specified index with a new long value.Updates an element at the specified index with a new short value.Updates an element at the specified index with a new string value.Replaces an element at the specified index with a new tag.intsize()Gets the number of elements in this list.toString()Generates a hierarchical string representation showing list metadata and elements.Methods inherited from class Collection_Tag
addAllTags, addTag, getAllTags, getAllTagsByName, getTag, getTagByName, removeAllTags, removeAllTagsByName, removeTag, removeTagByName
-
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:
-
addFloat
Adds a float element to this list with fluent chaining.Only valid for lists declared as float type.
- Specified by:
addFloatin interfaceIListTag- Parameters:
name- the element namevalue- the float value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Float- See Also:
-
addByte
Adds a byte element to this list with fluent chaining.Only valid for lists declared as byte type.
- Specified by:
addBytein interfaceIListTag- Parameters:
name- the element namevalue- the byte value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Byte- See Also:
-
addShort
Adds a short element to this list with fluent chaining.Only valid for lists declared as short type.
- Specified by:
addShortin interfaceIListTag- Parameters:
name- the element namevalue- the short value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Short- See Also:
-
addLong
Adds a long element to this list with fluent chaining.Only valid for lists declared as long type.
- Specified by:
addLongin interfaceIListTag- Parameters:
name- the element namevalue- the long value- Returns:
- this list tag for fluent operations
- Throws:
IllegalArgumentException- if list type is notTag_Long- See Also:
-
setString
Description copied from interface:IListTagUpdates an element at the specified index with a new string value. Only works if this list stores string tags. -
setInt
Description copied from interface:IListTagUpdates an element at the specified index with a new integer value. Only works if this list stores integer tags. -
setDouble
Description copied from interface:IListTagUpdates an element at the specified index with a new double value. Only works if this list stores double tags. -
setCompound
Description copied from interface:IListTagUpdates an element at the specified index with a new compound. Only works if this list stores compound tags.- Specified by:
setCompoundin interfaceIListTag- Parameters:
index- The index to updatename- The new element name- Returns:
- This list for fluent method chaining
-
setFloat
Description copied from interface:IListTagUpdates an element at the specified index with a new float value. Only works if this list stores float tags. -
setByte
Description copied from interface:IListTagUpdates an element at the specified index with a new byte value. Only works if this list stores byte tags. -
setShort
Description copied from interface:IListTagUpdates an element at the specified index with a new short value. Only works if this list stores short tags. -
setLong
Description copied from interface:IListTagUpdates an element at the specified index with a new long value. Only works if this list stores long tags. -
setTag
Description copied from interface:IListTagReplaces an element at the specified index with a new tag. -
removeAt
-
remove
-
clear
-
get
-
size
-
isEmpty
-
toString
Generates a hierarchical string representation showing list metadata and elements.Output includes tag type, name, element type, size, and formatted child elements.
-