Package net.minecraft.nbt
Class NbtList
- All Implemented Interfaces:
- Iterable<NbtElement>,- Collection<NbtElement>,- List<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 - official - qx- intermediary - net/minecraft/class_2499- named - net/minecraft/nbt/NbtList
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate static final intprivate byteprivate final List<NbtElement>Fields inherited from class java.util.AbstractListmodCountFields inherited from interface net.minecraft.nbt.NbtElementBYTE_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 SummaryConstructors
- 
Method SummaryModifier 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.AbstractListadd, addAll, indexOf, iterator, lastIndexOf, listIterator, listIterator, removeRange, subListMethods inherited from class java.util.AbstractCollectionaddAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArrayMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.CollectionparallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.ListaddAll, contains, containsAll, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArrayMethods inherited from interface net.minecraft.nbt.NbtElementaccept, asString
- 
Field Details- 
SIZEprivate static final int SIZE- See Also:
- Mappings:
- Namespace - Name - Mixin selector - official - b- Lqx;b:I- intermediary - field_41725- Lnet/minecraft/class_2499;field_41725:I- named - SIZE- Lnet/minecraft/nbt/NbtList;SIZE:I
 
- 
TYPE- Mappings:
- Namespace - Name - Mixin selector - official - a- Lqx;a:Lrm;- intermediary - field_21039- Lnet/minecraft/class_2499;field_21039:Lnet/minecraft/class_4614;- named - TYPE- Lnet/minecraft/nbt/NbtList;TYPE:Lnet/minecraft/nbt/NbtType;
 
- 
value- Mappings:
- Namespace - Name - Mixin selector - official - c- Lqx;c:Ljava/util/List;- intermediary - field_11550- Lnet/minecraft/class_2499;field_11550:Ljava/util/List;- named - value- Lnet/minecraft/nbt/NbtList;value:Ljava/util/List;
 
- 
typeprivate byte type- Mappings:
- Namespace - Name - Mixin selector - official - w- Lqx;w:B- intermediary - field_11551- Lnet/minecraft/class_2499;field_11551:B- named - type- Lnet/minecraft/nbt/NbtList;type:B
 
 
- 
- 
Constructor Details- 
NbtListNbtList(List<NbtElement> list, byte type) - Mappings:
- Namespace - Name - Mixin selector - official - <init>- Lqx;<init>(Ljava/util/List;B)V- intermediary - <init>- Lnet/minecraft/class_2499;<init>(Ljava/util/List;B)V- named - <init>- Lnet/minecraft/nbt/NbtList;<init>(Ljava/util/List;B)V
 
- 
NbtListpublic NbtList()
 
- 
- 
Method Details- 
writeWrites the NBT element tooutput.- Throws:
- IOException
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lrk;a(Ljava/io/DataOutput;)V- intermediary - method_10713- Lnet/minecraft/class_2520;method_10713(Ljava/io/DataOutput;)V- named - write- Lnet/minecraft/nbt/NbtElement;write(Ljava/io/DataOutput;)V
 
- 
getSizeInBytespublic int getSizeInBytes()- Mappings:
- Namespace - Name - Mixin selector - official - a- Lrk;a()I- intermediary - method_47988- Lnet/minecraft/class_2520;method_47988()I- named - getSizeInBytes- Lnet/minecraft/nbt/NbtElement;getSizeInBytes()I
 
- 
getTypepublic byte getType()Returns the type of this NBT element.- Returns:
- the type of this NBT element
- Mappings:
- Namespace - Name - Mixin selector - official - b- Lrk;b()B- intermediary - method_10711- Lnet/minecraft/class_2520;method_10711()B- named - getType- Lnet/minecraft/nbt/NbtElement;getType()B
 
- 
getNbtTypeReturns the NBT type definition of this NBT element.- Returns:
- the NBT type definition of this NBT element
- Mappings:
- Namespace - Name - Mixin selector - official - c- Lrk;c()Lrm;- intermediary - method_23258- Lnet/minecraft/class_2520;method_23258()Lnet/minecraft/class_4614;- named - getNbtType- Lnet/minecraft/nbt/NbtElement;getNbtType()Lnet/minecraft/nbt/NbtType;
 
- 
toString- Specified by:
- toStringin interface- NbtElement
- Overrides:
- toStringin class- AbstractCollection<NbtElement>
 
- 
forgetTypeIfEmptyprivate void forgetTypeIfEmpty()- Mappings:
- Namespace - Name - Mixin selector - official - g- Lqx;g()V- intermediary - method_17809- Lnet/minecraft/class_2499;method_17809()V- named - forgetTypeIfEmpty- Lnet/minecraft/nbt/NbtList;forgetTypeIfEmpty()V
 
- 
remove- Specified by:
- removein interface- List<NbtElement>
- Specified by:
- removein class- AbstractNbtList<NbtElement>
- Mappings:
- Namespace - Name - Mixin selector - official - method_10536- Lqx;method_10536(I)Lrk;- intermediary - method_10536- Lnet/minecraft/class_2499;method_10536(I)Lnet/minecraft/class_2520;- named - remove- Lnet/minecraft/nbt/NbtList;remove(I)Lnet/minecraft/nbt/NbtElement;
 
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Collection<NbtElement>
- Specified by:
- isEmptyin interface- List<NbtElement>
- Overrides:
- isEmptyin class- AbstractCollection<NbtElement>
 
- 
getCompoundReturns 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 - official - a- Lqx;a(I)Lqr;- intermediary - method_10602- Lnet/minecraft/class_2499;method_10602(I)Lnet/minecraft/class_2487;- named - getCompound- Lnet/minecraft/nbt/NbtList;getCompound(I)Lnet/minecraft/nbt/NbtCompound;
 
- 
getListReturns 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 - official - b- Lqx;b(I)Lqx;- intermediary - method_10603- Lnet/minecraft/class_2499;method_10603(I)Lnet/minecraft/class_2499;- named - getList- Lnet/minecraft/nbt/NbtList;getList(I)Lnet/minecraft/nbt/NbtList;
 
- 
getShortpublic 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 - official - d- Lqx;d(I)S- intermediary - method_10609- Lnet/minecraft/class_2499;method_10609(I)S- named - getShort- Lnet/minecraft/nbt/NbtList;getShort(I)S
 
- 
getIntpublic 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 - official - e- Lqx;e(I)I- intermediary - method_10600- Lnet/minecraft/class_2499;method_10600(I)I- named - getInt- Lnet/minecraft/nbt/NbtList;getInt(I)I
 
- 
getIntArraypublic 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 - official - f- Lqx;f(I)[I- intermediary - method_36111- Lnet/minecraft/class_2499;method_36111(I)[I- named - getIntArray- Lnet/minecraft/nbt/NbtList;getIntArray(I)[I
 
- 
getLongArraypublic 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 - official - g- Lqx;g(I)[J- intermediary - method_36112- Lnet/minecraft/class_2499;method_36112(I)[J- named - getLongArray- Lnet/minecraft/nbt/NbtList;getLongArray(I)[J
 
- 
getDoublepublic 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 - official - h- Lqx;h(I)D- intermediary - method_10611- Lnet/minecraft/class_2499;method_10611(I)D- named - getDouble- Lnet/minecraft/nbt/NbtList;getDouble(I)D
 
- 
getFloatpublic 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 - official - i- Lqx;i(I)F- intermediary - method_10604- Lnet/minecraft/class_2499;method_10604(I)F- named - getFloat- Lnet/minecraft/nbt/NbtList;getFloat(I)F
 
- 
getStringReturns 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 - official - j- Lqx;j(I)Ljava/lang/String;- intermediary - method_10608- Lnet/minecraft/class_2499;method_10608(I)Ljava/lang/String;- named - getString- Lnet/minecraft/nbt/NbtList;getString(I)Ljava/lang/String;
 
- 
sizepublic int size()- Specified by:
- sizein interface- Collection<NbtElement>
- Specified by:
- sizein interface- List<NbtElement>
- Specified by:
- sizein class- AbstractCollection<NbtElement>
 
- 
get- Specified by:
- getin interface- List<NbtElement>
- Specified by:
- getin class- AbstractList<NbtElement>
- Mappings:
- Namespace - Name - Mixin selector - official - k- Lqx;k(I)Lrk;- intermediary - method_10534- Lnet/minecraft/class_2499;method_10534(I)Lnet/minecraft/class_2520;- named - get- Lnet/minecraft/nbt/NbtList;get(I)Lnet/minecraft/nbt/NbtElement;
 
- 
set- Specified by:
- setin interface- List<NbtElement>
- Specified by:
- setin class- AbstractNbtList<NbtElement>
- Mappings:
- Namespace - Name - Mixin selector - official - method_10606- Lqx;method_10606(ILrk;)Lrk;- intermediary - method_10606- Lnet/minecraft/class_2499;method_10606(ILnet/minecraft/class_2520;)Lnet/minecraft/class_2520;- named - set- Lnet/minecraft/nbt/NbtList;set(ILnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;
 
- 
add- Specified by:
- addin interface- List<NbtElement>
- Specified by:
- addin class- AbstractNbtList<NbtElement>
- Mappings:
- Namespace - Name - Mixin selector - official - method_10531- Lqx;method_10531(ILrk;)V- intermediary - method_10531- Lnet/minecraft/class_2499;method_10531(ILnet/minecraft/class_2520;)V- named - add- Lnet/minecraft/nbt/NbtList;add(ILnet/minecraft/nbt/NbtElement;)V
 
- 
setElementSets the element atindextoelement. Does nothing if the types were incompatible.- Specified by:
- setElementin class- AbstractNbtList<NbtElement>
- Returns:
- whether the element was actually set
- Mappings:
- Namespace - Name - Mixin selector - official - a- Lqq;a(ILrk;)Z- intermediary - method_10535- Lnet/minecraft/class_2483;method_10535(ILnet/minecraft/class_2520;)Z- named - setElement- Lnet/minecraft/nbt/AbstractNbtList;setElement(ILnet/minecraft/nbt/NbtElement;)Z
 
- 
addElementInsertselementatindex. Does nothing if the types were incompatible.- Specified by:
- addElementin class- AbstractNbtList<NbtElement>
- Returns:
- whether the element was actually added
- Mappings:
- Namespace - Name - Mixin selector - official - b- Lqq;b(ILrk;)Z- intermediary - method_10533- Lnet/minecraft/class_2483;method_10533(ILnet/minecraft/class_2520;)Z- named - addElement- Lnet/minecraft/nbt/AbstractNbtList;addElement(ILnet/minecraft/nbt/NbtElement;)Z
 
- 
canAdd- Mappings:
- Namespace - Name - Mixin selector - official - a- Lqx;a(Lrk;)Z- intermediary - method_10605- Lnet/minecraft/class_2499;method_10605(Lnet/minecraft/class_2520;)Z- named - canAdd- Lnet/minecraft/nbt/NbtList;canAdd(Lnet/minecraft/nbt/NbtElement;)Z
 
- 
copyDescription 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 - official - e- Lqx;e()Lqx;- intermediary - method_10612- Lnet/minecraft/class_2499;method_10612()Lnet/minecraft/class_2499;- named - copy- Lnet/minecraft/nbt/NbtList;copy()Lnet/minecraft/nbt/NbtList;
 
- 
equals- Specified by:
- equalsin interface- Collection<NbtElement>
- Specified by:
- equalsin interface- List<NbtElement>
- Overrides:
- equalsin class- AbstractList<NbtElement>
- Mappings:
- Namespace - Name - Mixin selector - official - equals- Lqx;equals(Ljava/lang/Object;)Z- intermediary - equals- Lnet/minecraft/class_2499;equals(Ljava/lang/Object;)Z- named - equals- Lnet/minecraft/nbt/NbtList;equals(Ljava/lang/Object;)Z
 
- 
hashCodepublic int hashCode()- Specified by:
- hashCodein interface- Collection<NbtElement>
- Specified by:
- hashCodein interface- List<NbtElement>
- Overrides:
- hashCodein class- AbstractList<NbtElement>
 
- 
accept- Mappings:
- Namespace - Name - Mixin selector - official - a- Lrk;a(Lro;)V- intermediary - method_32289- Lnet/minecraft/class_2520;method_32289(Lnet/minecraft/class_5627;)V- named - accept- Lnet/minecraft/nbt/NbtElement;accept(Lnet/minecraft/nbt/visitor/NbtElementVisitor;)V
 
- 
getHeldTypepublic byte getHeldType()Gets the type of element that this list holds.- Specified by:
- getHeldTypein class- AbstractNbtList<NbtElement>
- Returns:
- the type of element that this list holds
- Mappings:
- Namespace - Name - Mixin selector - official - f- Lqq;f()B- intermediary - method_10601- Lnet/minecraft/class_2483;method_10601()B- named - getHeldType- Lnet/minecraft/nbt/AbstractNbtList;getHeldType()B
 
- 
clearpublic void clear()- Specified by:
- clearin interface- Collection<NbtElement>
- Specified by:
- clearin interface- List<NbtElement>
- Overrides:
- clearin class- AbstractList<NbtElement>
 
- 
doAccept- Mappings:
- Namespace - Name - Mixin selector - official - a- Lrk;a(Lrh;)Lrh$b;- intermediary - method_39850- Lnet/minecraft/class_2520;method_39850(Lnet/minecraft/class_6836;)Lnet/minecraft/class_6836$class_6838;- named - doAccept- Lnet/minecraft/nbt/NbtElement;doAccept(Lnet/minecraft/nbt/scanner/NbtScanner;)Lnet/minecraft/nbt/scanner/NbtScanner$Result;
 
 
-