Package net.minecraft.nbt
Class NbtList
- All Implemented Interfaces:
Iterable<NbtElement>,Collection<NbtElement>,List<NbtElement>,SequencedCollection<NbtElement>,NbtElement
Represents a mutable NBT list. Its type is 0x9.
An NBT list holds values of the same NBT type.
The NBT type of an NBT list is determined
once its first element is inserted; empty NBT lists return NbtElement.END_TYPE
as their held NBT type.
To get values from this list, use methods with type names, such as
getInt(int). Where applicable, these methods return Java types (e.g. int,
long[]) instead of NbtElement subclasses. If type mismatch occurs or
the index is out of bounds, it returns the default value for that type instead of
throwing or returning null.
Unlike NbtCompound, there is no Java type-based adder, and numeric value
getters will not try to cast the values.
- Mappings:
Namespace Name named net/minecraft/nbt/NbtListintermediary net/minecraft/class_2499official uh
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate byteprivate final List<NbtElement> Fields inherited from class java.util.AbstractList
modCountFields inherited from interface net.minecraft.nbt.NbtElement
BYTE_ARRAY_TYPE, BYTE_TYPE, COMPOUND_TYPE, DOUBLE_TYPE, END_TYPE, field_33246, field_33247, field_33248, field_33249, FLOAT_TYPE, INT_ARRAY_TYPE, INT_TYPE, LIST_TYPE, LONG_ARRAY_TYPE, LONG_TYPE, MAX_DEPTH, NUMBER_TYPE, SHORT_TYPE, STRING_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaccept(NbtElementVisitor visitor) voidadd(int int2, NbtElement nbtElement) booleanaddElement(int index, NbtElement element) Insertselementatindex.private booleancanAdd(NbtElement element) voidclear()copy()Returns an NBT element of equal value that won't change with this element.doAccept(NbtScanner visitor) booleanprivate voidget(int int2) getCompound(int index) Returns the compound atindex, or an empty compound if the index is out of bounds or if this is not a list of compounds.doublegetDouble(int index) Returns the double atindex, or0.0if the index is out of bounds or if this is not a list of doubles.floatgetFloat(int index) Returns the float atindex, or0.0fif the index is out of bounds or if this is not a list of floats.byteGets the type of element that this list holds.intgetInt(int index) Returns the integer atindex, or0if the index is out of bounds or if this is not a list of integers.int[]getIntArray(int index) Returns the int array atindex, or an empty int array if the index is out of bounds or if this is not a list of int arrays.getList(int index) Returns the list atindex, or an empty list if the index is out of bounds or if this is not a list of lists.long[]getLongArray(int index) Returns the long array atindex, or an empty int array if the index is out of bounds or if this is not a list of long arrays.Returns the NBT type definition of this NBT element.shortgetShort(int index) Returns the short atindex, or0if the index is out of bounds or if this is not a list of shorts.intgetString(int index) Returns the stringified value atindex, or an empty string if the index is out of bounds.bytegetType()Returns the type of this NBT element.inthashCode()booleanisEmpty()remove(int int2) set(int int2, NbtElement nbtElement) booleansetElement(int index, NbtElement element) Sets the element atindextoelement.intsize()toString()voidwrite(DataOutput output) Writes the NBT element tooutput.Methods inherited from class java.util.AbstractList
add, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
addAll, addFirst, addLast, contains, containsAll, getFirst, getLast, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, sort, spliterator, toArray, toArrayMethods inherited from interface net.minecraft.nbt.NbtElement
accept, asString
-
Field Details
-
SIZE
private static final int SIZE- See Also:
- Mappings:
Namespace Name Mixin selector named SIZELnet/minecraft/nbt/NbtList;SIZE:Iintermediary field_41725Lnet/minecraft/class_2499;field_41725:Iofficial bLuh;b:I
-
TYPE
- Mappings:
Namespace Name Mixin selector named TYPELnet/minecraft/nbt/NbtList;TYPE:Lnet/minecraft/nbt/NbtType;intermediary field_21039Lnet/minecraft/class_2499;field_21039:Lnet/minecraft/class_4614;official aLuh;a:Lva;
-
value
- Mappings:
Namespace Name Mixin selector named valueLnet/minecraft/nbt/NbtList;value:Ljava/util/List;intermediary field_11550Lnet/minecraft/class_2499;field_11550:Ljava/util/List;official cLuh;c:Ljava/util/List;
-
type
private byte type- Mappings:
Namespace Name Mixin selector named typeLnet/minecraft/nbt/NbtList;type:Bintermediary field_11551Lnet/minecraft/class_2499;field_11551:Bofficial wLuh;w:B
-
-
Constructor Details
-
NbtList
NbtList(List<NbtElement> list, byte type) - Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/nbt/NbtList;<init>(Ljava/util/List;B)Vintermediary <init>Lnet/minecraft/class_2499;<init>(Ljava/util/List;B)Vofficial <init>Luh;<init>(Ljava/util/List;B)V
-
NbtList
public NbtList()
-
-
Method Details
-
write
Writes the NBT element tooutput.- Throws:
IOException- API Note:
- This is a low-level method for serializing NBT elements; consider using
NbtIo,NbtOps, orPacketByteBuf.writeNbt(net.minecraft.nbt.NbtElement)instead. - Mappings:
Namespace Name Mixin selector named writeLnet/minecraft/nbt/NbtElement;write(Ljava/io/DataOutput;)Vintermediary method_10713Lnet/minecraft/class_2520;method_10713(Ljava/io/DataOutput;)Vofficial aLuy;a(Ljava/io/DataOutput;)V
-
getSizeInBytes
public int getSizeInBytes()- Mappings:
Namespace Name Mixin selector named getSizeInBytesLnet/minecraft/nbt/NbtElement;getSizeInBytes()Iintermediary method_47988Lnet/minecraft/class_2520;method_47988()Iofficial aLuy;a()I
-
getType
public byte getType()Returns the type of this NBT element.- Returns:
- the type of this NBT element
- Mappings:
Namespace Name Mixin selector named getTypeLnet/minecraft/nbt/NbtElement;getType()Bintermediary method_10711Lnet/minecraft/class_2520;method_10711()Bofficial bLuy;b()B
-
getNbtType
Returns the NBT type definition of this NBT element.- Returns:
- the NBT type definition of this NBT element
- Mappings:
Namespace Name Mixin selector named getNbtTypeLnet/minecraft/nbt/NbtElement;getNbtType()Lnet/minecraft/nbt/NbtType;intermediary method_23258Lnet/minecraft/class_2520;method_23258()Lnet/minecraft/class_4614;official cLuy;c()Lva;
-
toString
- Specified by:
toStringin interfaceNbtElement- Overrides:
toStringin classAbstractCollection<NbtElement>
-
forgetTypeIfEmpty
private void forgetTypeIfEmpty()- Mappings:
Namespace Name Mixin selector named forgetTypeIfEmptyLnet/minecraft/nbt/NbtList;forgetTypeIfEmpty()Vintermediary method_17809Lnet/minecraft/class_2499;method_17809()Vofficial gLuh;g()V
-
remove
- Specified by:
removein interfaceList<NbtElement>- Specified by:
removein classAbstractNbtList<NbtElement>- Mappings:
Namespace Name Mixin selector named removeLnet/minecraft/nbt/NbtList;remove(I)Lnet/minecraft/nbt/NbtElement;intermediary method_10536Lnet/minecraft/class_2499;method_10536(I)Lnet/minecraft/class_2520;official method_10536Luh;method_10536(I)Luy;
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<NbtElement>- Specified by:
isEmptyin interfaceList<NbtElement>- Overrides:
isEmptyin classAbstractCollection<NbtElement>
-
getCompound
Returns the compound atindex, or an empty compound if the index is out of bounds or if this is not a list of compounds.- Returns:
- the compound at
index, or an empty compound if the index is out of bounds or if this is not a list of compounds - Mappings:
Namespace Name Mixin selector named getCompoundLnet/minecraft/nbt/NbtList;getCompound(I)Lnet/minecraft/nbt/NbtCompound;intermediary method_10602Lnet/minecraft/class_2499;method_10602(I)Lnet/minecraft/class_2487;official aLuh;a(I)Lub;
-
getList
Returns the list atindex, or an empty list if the index is out of bounds or if this is not a list of lists.- Returns:
- the list at
index, or an empty list if the index is out of bounds or if this is not a list of lists - Mappings:
Namespace Name Mixin selector named getListLnet/minecraft/nbt/NbtList;getList(I)Lnet/minecraft/nbt/NbtList;intermediary method_10603Lnet/minecraft/class_2499;method_10603(I)Lnet/minecraft/class_2499;official bLuh;b(I)Luh;
-
getShort
public short getShort(int index) Returns the short atindex, or0if the index is out of bounds or if this is not a list of shorts.- Returns:
- the short at
index, or0if the index is out of bounds or if this is not a list of shorts - Mappings:
Namespace Name Mixin selector named getShortLnet/minecraft/nbt/NbtList;getShort(I)Sintermediary method_10609Lnet/minecraft/class_2499;method_10609(I)Sofficial dLuh;d(I)S
-
getInt
public int getInt(int index) Returns the integer atindex, or0if the index is out of bounds or if this is not a list of integers.- Returns:
- the integer at
index, or0if the index is out of bounds or if this is not a list of integers - Mappings:
Namespace Name Mixin selector named getIntLnet/minecraft/nbt/NbtList;getInt(I)Iintermediary method_10600Lnet/minecraft/class_2499;method_10600(I)Iofficial eLuh;e(I)I
-
getIntArray
public int[] getIntArray(int index) Returns the int array atindex, or an empty int array if the index is out of bounds or if this is not a list of int arrays.- Returns:
- the int array at
index, or an empty int array if the index is out of bounds or if this is not a list of int arrays - API Note:
- Modifying the returned array also modifies the NBT int array.
- Mappings:
Namespace Name Mixin selector named getIntArrayLnet/minecraft/nbt/NbtList;getIntArray(I)[Iintermediary method_36111Lnet/minecraft/class_2499;method_36111(I)[Iofficial fLuh;f(I)[I
-
getLongArray
public long[] getLongArray(int index) Returns the long array atindex, or an empty int array if the index is out of bounds or if this is not a list of long arrays.- Returns:
- the long array at
index, or an empty int array if the index is out of bounds or if this is not a list of long arrays - API Note:
- Modifying the returned array also modifies the NBT long array.
- Mappings:
Namespace Name Mixin selector named getLongArrayLnet/minecraft/nbt/NbtList;getLongArray(I)[Jintermediary method_36112Lnet/minecraft/class_2499;method_36112(I)[Jofficial gLuh;g(I)[J
-
getDouble
public double getDouble(int index) Returns the double atindex, or0.0if the index is out of bounds or if this is not a list of doubles.- Returns:
- the double at
index, or0.0if the index is out of bounds or if this is not a list of doubles - Mappings:
Namespace Name Mixin selector named getDoubleLnet/minecraft/nbt/NbtList;getDouble(I)Dintermediary method_10611Lnet/minecraft/class_2499;method_10611(I)Dofficial hLuh;h(I)D
-
getFloat
public float getFloat(int index) Returns the float atindex, or0.0fif the index is out of bounds or if this is not a list of floats.- Returns:
- the float at
index, or0.0fif the index is out of bounds or if this is not a list of floats - Mappings:
Namespace Name Mixin selector named getFloatLnet/minecraft/nbt/NbtList;getFloat(I)Fintermediary method_10604Lnet/minecraft/class_2499;method_10604(I)Fofficial iLuh;i(I)F
-
getString
Returns the stringified value atindex, or an empty string if the index is out of bounds.Unlike other getters, this works with any type, not just
NbtString.- Returns:
- the stringified value at
index, or an empty string if the index is out of bounds - Mappings:
Namespace Name Mixin selector named getStringLnet/minecraft/nbt/NbtList;getString(I)Ljava/lang/String;intermediary method_10608Lnet/minecraft/class_2499;method_10608(I)Ljava/lang/String;official jLuh;j(I)Ljava/lang/String;
-
size
public int size()- Specified by:
sizein interfaceCollection<NbtElement>- Specified by:
sizein interfaceList<NbtElement>- Specified by:
sizein classAbstractCollection<NbtElement>
-
get
- Specified by:
getin interfaceList<NbtElement>- Specified by:
getin classAbstractList<NbtElement>- Mappings:
Namespace Name Mixin selector named getLnet/minecraft/nbt/NbtList;get(I)Lnet/minecraft/nbt/NbtElement;intermediary method_10534Lnet/minecraft/class_2499;method_10534(I)Lnet/minecraft/class_2520;official kLuh;k(I)Luy;
-
set
- Specified by:
setin interfaceList<NbtElement>- Specified by:
setin classAbstractNbtList<NbtElement>- Mappings:
Namespace Name Mixin selector named setLnet/minecraft/nbt/NbtList;set(ILnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;intermediary method_10606Lnet/minecraft/class_2499;method_10606(ILnet/minecraft/class_2520;)Lnet/minecraft/class_2520;official method_10606Luh;method_10606(ILuy;)Luy;
-
add
- Specified by:
addin interfaceList<NbtElement>- Specified by:
addin classAbstractNbtList<NbtElement>- Mappings:
Namespace Name Mixin selector named addLnet/minecraft/nbt/NbtList;add(ILnet/minecraft/nbt/NbtElement;)Vintermediary method_10531Lnet/minecraft/class_2499;method_10531(ILnet/minecraft/class_2520;)Vofficial method_10531Luh;method_10531(ILuy;)V
-
setElement
Sets the element atindextoelement. Does nothing if the types were incompatible.- Specified by:
setElementin classAbstractNbtList<NbtElement>- Returns:
- whether the element was actually set
- Mappings:
Namespace Name Mixin selector named setElementLnet/minecraft/nbt/AbstractNbtList;setElement(ILnet/minecraft/nbt/NbtElement;)Zintermediary method_10535Lnet/minecraft/class_2483;method_10535(ILnet/minecraft/class_2520;)Zofficial aLua;a(ILuy;)Z
-
addElement
Insertselementatindex. Does nothing if the types were incompatible.- Specified by:
addElementin classAbstractNbtList<NbtElement>- Returns:
- whether the element was actually added
- Mappings:
Namespace Name Mixin selector named addElementLnet/minecraft/nbt/AbstractNbtList;addElement(ILnet/minecraft/nbt/NbtElement;)Zintermediary method_10533Lnet/minecraft/class_2483;method_10533(ILnet/minecraft/class_2520;)Zofficial bLua;b(ILuy;)Z
-
canAdd
- Mappings:
Namespace Name Mixin selector named canAddLnet/minecraft/nbt/NbtList;canAdd(Lnet/minecraft/nbt/NbtElement;)Zintermediary method_10605Lnet/minecraft/class_2499;method_10605(Lnet/minecraft/class_2520;)Zofficial aLuh;a(Luy;)Z
-
copy
Description copied from interface:NbtElementReturns an NBT element of equal value that won't change with this element.- Returns:
- an NBT element of equal value that won't change with this element
- Mappings:
Namespace Name Mixin selector named copyLnet/minecraft/nbt/NbtList;copy()Lnet/minecraft/nbt/NbtList;intermediary method_10612Lnet/minecraft/class_2499;method_10612()Lnet/minecraft/class_2499;official eLuh;e()Luh;
-
equals
- Specified by:
equalsin interfaceCollection<NbtElement>- Specified by:
equalsin interfaceList<NbtElement>- Overrides:
equalsin classAbstractList<NbtElement>- Mappings:
Namespace Name Mixin selector named equalsLnet/minecraft/nbt/NbtList;equals(Ljava/lang/Object;)Zintermediary equalsLnet/minecraft/class_2499;equals(Ljava/lang/Object;)Zofficial equalsLuh;equals(Ljava/lang/Object;)Z
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<NbtElement>- Specified by:
hashCodein interfaceList<NbtElement>- Overrides:
hashCodein classAbstractList<NbtElement>
-
accept
- Mappings:
Namespace Name Mixin selector named acceptLnet/minecraft/nbt/NbtElement;accept(Lnet/minecraft/nbt/visitor/NbtElementVisitor;)Vintermediary method_32289Lnet/minecraft/class_2520;method_32289(Lnet/minecraft/class_5627;)Vofficial aLuy;a(Lvc;)V
-
getHeldType
public byte getHeldType()Gets the type of element that this list holds.- Specified by:
getHeldTypein classAbstractNbtList<NbtElement>- Returns:
- the type of element that this list holds
- Mappings:
Namespace Name Mixin selector named getHeldTypeLnet/minecraft/nbt/AbstractNbtList;getHeldType()Bintermediary method_10601Lnet/minecraft/class_2483;method_10601()Bofficial fLua;f()B
-
clear
public void clear()- Specified by:
clearin interfaceCollection<NbtElement>- Specified by:
clearin interfaceList<NbtElement>- Overrides:
clearin classAbstractList<NbtElement>
-
doAccept
- Mappings:
Namespace Name Mixin selector named doAcceptLnet/minecraft/nbt/NbtElement;doAccept(Lnet/minecraft/nbt/scanner/NbtScanner;)Lnet/minecraft/nbt/scanner/NbtScanner$Result;intermediary method_39850Lnet/minecraft/class_2520;method_39850(Lnet/minecraft/class_6836;)Lnet/minecraft/class_6836$class_6838;official aLuy;a(Luv;)Luv$b;
-