Interface IListTag
- All Known Implementing Classes:
Tag_List
Interface for NBT list tags - ordered collections of same-type elements.
Lists enforce type homogeneity, meaning all elements must be of the same NBT type.
They're perfect for storing arrays of data like inventory items, coordinates, or any sequential information.
- Author:
- Paul Ferlitz
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdds a byte element to this list.addCompound(String name) Adds an empty compound element to this list.Adds a double-precision floating point element to this list.Adds a float element to this list.Adds an integer element to this list.Adds a long element to this list.Adds a short element to this list.Adds a string element to this list.clear()Removes all elements from this list.ITag<?> get(int index) Gets the element at the specified index.intReturns the NBT type ID that all elements in this list must have.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.
-
Method Details
-
getListTypeID
int getListTypeID()Returns the NBT type ID that all elements in this list must have. Once set, this cannot be changed and all added elements must match this type.- Returns:
- The required element type ID (0-12)
-
addString
Adds a string element to this list. Only works if this list stores string tags.- Parameters:
name- The element namevalue- TheStringvalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store string tags
-
addInt
Adds an integer element to this list. Only works if this list stores integer tags.- Parameters:
name- The element namevalue- TheIntegervalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store integer tags
-
addDouble
Adds a double-precision floating point element to this list. Only works if this list stores double tags.- Parameters:
name- The element namevalue- TheDoublevalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store double tags
-
addCompound
Adds an empty compound element to this list. Only works if this list stores compound tags.- Parameters:
name- The element name- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store compound tags
-
addFloat
Adds a float element to this list. Only works if this list stores float tags.- Parameters:
name- The element namevalue- TheFloatvalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store float tags
-
addByte
Adds a byte element to this list. Only works if this list stores byte tags.- Parameters:
name- The element namevalue- TheBytevalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store byte tags
-
addShort
Adds a short element to this list. Only works if this list stores short tags.- Parameters:
name- The element namevalue- TheShortvalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store short tags
-
addLong
Adds a long element to this list. Only works if this list stores long tags.- Parameters:
name- The element namevalue- TheLongvalue to store- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store long tags
-
setString
Updates an element at the specified index with a new string value. Only works if this list stores string tags.- Parameters:
index- The index to updatename- The new element namevalue- The newStringvalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store string tagsIndexOutOfBoundsException- if index is invalid
-
setInt
Updates an element at the specified index with a new integer value. Only works if this list stores integer tags.- Parameters:
index- The index to updatename- The new element namevalue- The newIntegervalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store integer tagsIndexOutOfBoundsException- if index is invalid
-
setDouble
Updates an element at the specified index with a new double value. Only works if this list stores double tags.- Parameters:
index- The index to updatename- The new element namevalue- The newDoublevalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store double tagsIndexOutOfBoundsException- if index is invalid
-
setCompound
Updates an element at the specified index with a new compound. Only works if this list stores compound tags.- Parameters:
index- The index to updatename- The new element name- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store compound tagsIndexOutOfBoundsException- if index is invalid
-
setFloat
Updates an element at the specified index with a new float value. Only works if this list stores float tags.- Parameters:
index- The index to updatename- The new element namevalue- The newFloatvalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store float tagsIndexOutOfBoundsException- if index is invalid
-
setByte
Updates an element at the specified index with a new byte value. Only works if this list stores byte tags.- Parameters:
index- The index to updatename- The new element namevalue- The newBytevalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store byte tagsIndexOutOfBoundsException- if index is invalid
-
setShort
Updates an element at the specified index with a new short value. Only works if this list stores short tags.- Parameters:
index- The index to updatename- The new element namevalue- The newShortvalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store short tagsIndexOutOfBoundsException- if index is invalid
-
setLong
Updates an element at the specified index with a new long value. Only works if this list stores long tags.- Parameters:
index- The index to updatename- The new element namevalue- The newLongvalue- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if this list doesn't store long tagsIndexOutOfBoundsException- if index is invalid
-
setTag
Replaces an element at the specified index with a new tag.- Parameters:
index- The index to updatetag- The new tag to set- Returns:
- This list for fluent method chaining
- Throws:
IllegalArgumentException- if tag type doesn't match list typeIndexOutOfBoundsException- if index is invalid
-
removeAt
Removes an element at the specified index.- Parameters:
index- The index to remove- Returns:
- This list for fluent method chaining
- Throws:
IndexOutOfBoundsException- if index is invalid
-
remove
-
clear
-
get
Gets the element at the specified index.- Parameters:
index- The index to retrieve- Returns:
- The element at the specified index
- Throws:
IndexOutOfBoundsException- if index is invalid
-
size
int size()Gets the number of elements in this list.- Returns:
- The number of elements
-
isEmpty
boolean isEmpty()Checks if this list is empty (has no elements).- Returns:
trueif empty,falseotherwise
-