TType
- - the value type of each NBT tag.public interface NbtList<TType> extends NbtBase<java.util.List<NbtBase<TType>>>, java.lang.Iterable<TType>
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EMPTY_NAME
The name of every NBT tag in a list.
|
Modifier and Type | Method and Description |
---|---|
void |
add(byte value)
Add a new byte element to the list.
|
void |
add(byte[] value)
Add a new byte array element to the list.
|
void |
add(double value)
Add a new double element to the list.
|
void |
add(int value)
Add a new integer element to the list.
|
void |
add(int[] value)
Add a new int array element to the list.
|
void |
add(long value)
Add a new long element to the list.
|
void |
add(NbtBase<TType> element)
Add a NBT list or NBT compound to the list.
|
void |
add(short value)
Add a new short element to the list.
|
void |
add(java.lang.String value)
Add a new string element to the list.
|
void |
addClosest(java.lang.Object value)
Add a value to a typed list by attempting to convert it to the nearest value.
|
java.util.Collection<NbtBase<TType>> |
asCollection()
Retrieve each NBT tag in this list.
|
NbtType |
getElementType()
Get the type of each element.
|
TType |
getValue(int index)
Retrieve an element by index.
|
java.util.Iterator<TType> |
iterator()
Iterate over all the elements in this list.
|
void |
remove(java.lang.Object remove)
Remove a given object from the list.
|
void |
setElementType(NbtType type)
Set the type of each element.
|
int |
size()
Retrieve the number of elements in this list.
|
static final java.lang.String EMPTY_NAME
NbtType getElementType()
This will be TAG_END
if the NBT list has just been created.
void setElementType(NbtType type)
type
- - type of each element.void addClosest(java.lang.Object value)
Note that the list must be typed by setting setElementType(NbtType)
before calling this function.
value
- - the value to add.void add(NbtBase<TType> element)
element
- void add(java.lang.String value)
value
- - the string element to add.java.lang.IllegalArgumentException
- If this is not a list of strings.void add(byte value)
value
- - the byte element to add.java.lang.IllegalArgumentException
- If this is not a list of bytes.void add(short value)
value
- - the short element to add.java.lang.IllegalArgumentException
- If this is not a list of shorts.void add(int value)
value
- - the string element to add.java.lang.IllegalArgumentException
- If this is not a list of integers.void add(long value)
value
- - the string element to add.java.lang.IllegalArgumentException
- If this is not a list of longs.void add(double value)
value
- - the double element to add.java.lang.IllegalArgumentException
- If this is not a list of doubles.void add(byte[] value)
value
- - the byte array element to add.java.lang.IllegalArgumentException
- If this is not a list of byte arrays.void add(int[] value)
value
- - the int array element to add.java.lang.IllegalArgumentException
- If this is not a list of int arrays.void remove(java.lang.Object remove)
remove
- - the object to remove.TType getValue(int index)
index
- - index of the element to retrieve.java.lang.IndexOutOfBoundsException
- If the index is out of range (index < 0 || index >= size())int size()
java.util.Collection<NbtBase<TType>> asCollection()