Interface NbtList<TType>
- Type Parameters:
TType- - the value type of each NBT tag.
- All Superinterfaces:
ClonableWrapper,Iterable<TType>,NbtBase<List<NbtBase<TType>>>
Represents a list of NBT tags of the same type without names.
Use NbtFactory to load or create an instance.
The NbtBase.getValue() method returns a List that will correctly return the content
of this NBT list, but may throw an UnsupportedOperationException for any of the write operations.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(byte value) Add a new byte element to the list.voidadd(byte[] value) Add a new byte array element to the list.voidadd(double value) Add a new double element to the list.voidadd(int value) Add a new integer element to the list.voidadd(int[] value) Add a new int array element to the list.voidadd(long value) Add a new long element to the list.voidadd(short value) Add a new short element to the list.voidAdd a NBT list or NBT compound to the list.voidAdd a new string element to the list.voidaddClosest(Object value) Add a value to a typed list by attempting to convert it to the nearest value.Retrieve each NBT tag in this list.Get the type of each element.getValue(int index) Retrieve an element by index.iterator()Iterate over all the elements in this list.voidRemove a given object from the list.voidsetElementType(NbtType type) Set the type of each element.intsize()Retrieve the number of elements in this list.Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
EMPTY_NAME
The name of every NBT tag in a list.- See Also:
-
-
Method Details
-
getElementType
NbtType getElementType()Get the type of each element.This will be
TAG_ENDif the NBT list has just been created.- Returns:
- Element type.
-
setElementType
Set the type of each element.- Parameters:
type- - type of each element.
-
addClosest
Add a value to a typed list by attempting to convert it to the nearest value.Note that the list must be typed by setting
setElementType(NbtType)before calling this function.- Parameters:
value- - the value to add.
-
add
Add a NBT list or NBT compound to the list.- Parameters:
element- Element to add
-
add
Add a new string element to the list.- Parameters:
value- - the string element to add.- Throws:
IllegalArgumentException- If this is not a list of strings.
-
add
void add(byte value) Add a new byte element to the list.- Parameters:
value- - the byte element to add.- Throws:
IllegalArgumentException- If this is not a list of bytes.
-
add
void add(short value) Add a new short element to the list.- Parameters:
value- - the short element to add.- Throws:
IllegalArgumentException- If this is not a list of shorts.
-
add
void add(int value) Add a new integer element to the list.- Parameters:
value- - the string element to add.- Throws:
IllegalArgumentException- If this is not a list of integers.
-
add
void add(long value) Add a new long element to the list.- Parameters:
value- - the string element to add.- Throws:
IllegalArgumentException- If this is not a list of longs.
-
add
void add(double value) Add a new double element to the list.- Parameters:
value- - the double element to add.- Throws:
IllegalArgumentException- If this is not a list of doubles.
-
add
void add(byte[] value) Add a new byte array element to the list.- Parameters:
value- - the byte array element to add.- Throws:
IllegalArgumentException- If this is not a list of byte arrays.
-
add
void add(int[] value) Add a new int array element to the list.- Parameters:
value- - the int array element to add.- Throws:
IllegalArgumentException- If this is not a list of int arrays.
-
remove
Remove a given object from the list.- Parameters:
remove- - the object to remove.
-
getValue
Retrieve an element by index.- Parameters:
index- - index of the element to retrieve.- Returns:
- The element to retrieve.
- Throws:
IndexOutOfBoundsException- If the index is out of range
-
size
int size()Retrieve the number of elements in this list.- Returns:
- The number of elements in this list.
-
asCollection
Collection<NbtBase<TType>> asCollection()Retrieve each NBT tag in this list.- Returns:
- A view of NBT tag in this list.
-
iterator
Iterate over all the elements in this list.
-