Package net.minecraft.nbt
Class NbtList
- All Implemented Interfaces:
Iterable<NbtElement>,Collection<NbtElement>,List<NbtElement>,SequencedCollection<NbtElement>,AbstractNbtList,NbtElement
Represents a mutable NBT list. Its type is 0x9.
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 uv
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final intprivate 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, 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.voidclear()private static NbtCompoundcopy()Returns an NBT element of equal value that won't change with this element.doAccept(NbtScanner visitor) booleanget(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.getCompoundOrEmpty(int index) getDouble(int index) Returns the double atindex, or0.0if the index is out of bounds or if this is not a list of doubles.doublegetDouble(int index, double fallback) getFloat(int index) Returns the float atindex, or0.0fif the index is out of bounds or if this is not a list of floats.floatgetFloat(int index, float fallback) getInt(int index) Returns the integer atindex, or0if the index is out of bounds or if this is not a list of integers.intgetInt(int index, int fallback) Optional<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.getListOrEmpty(int index) Optional<long[]> getLongArray(int index) Returns the long array atindex, or an empty long 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.private @Nullable NbtElementgetNullable(int index) private Optional<NbtElement> getOptional(int index) getShort(int index) Returns the short atindex, or0if the index is out of bounds or if this is not a list of shorts.shortgetShort(int index, short fallback) 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.(package private) byteinthashCode()private static booleanbooleanisEmpty()remove(int int2) set(int int2, NbtElement nbtElement) booleansetElement(int index, NbtElement element) Sets the element atindextoelement.intsize()stream()toString()private static NbtElementunwrap(NbtCompound nbt) voidunwrapAndAdd(NbtElement nbt) private static NbtElementwrapIfNeeded(byte type, NbtElement value) 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 net.minecraft.nbt.AbstractNbtList
iteratorMethods inherited from interface java.util.Collection
parallelStream, removeIf, 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, asBoolean, asByte, asByteArray, asCompound, asDouble, asFloat, asInt, asIntArray, asLong, asLongArray, asNumber, asShort, asString
-
Field Details
-
HOMOGENIZED_ENTRY_KEY
- See Also:
- Mappings:
Namespace Name Mixin selector named HOMOGENIZED_ENTRY_KEYLnet/minecraft/nbt/NbtList;HOMOGENIZED_ENTRY_KEY:Ljava/lang/String;intermediary field_57977Lnet/minecraft/class_2499;field_57977:Ljava/lang/String;official bLuv;b:Ljava/lang/String;
-
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 cLuv;c: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 aLuv;a:Lvr;
-
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 vLuv;v:Ljava/util/List;
-
-
Constructor Details
-
NbtList
public NbtList() -
NbtList
NbtList(List<NbtElement> value) - Mappings:
Namespace Name Mixin selector named <init>Lnet/minecraft/nbt/NbtList;<init>(Ljava/util/List;)Vintermediary <init>Lnet/minecraft/class_2499;<init>(Ljava/util/List;)Vofficial <init>Luv;<init>(Ljava/util/List;)V
-
-
Method Details
-
unwrap
- Mappings:
Namespace Name Mixin selector named unwrapLnet/minecraft/nbt/NbtList;unwrap(Lnet/minecraft/nbt/NbtCompound;)Lnet/minecraft/nbt/NbtElement;intermediary method_68579Lnet/minecraft/class_2499;method_68579(Lnet/minecraft/class_2487;)Lnet/minecraft/class_2520;official aLuv;a(Lup;)Lvp;
-
isConvertedEntry
- Mappings:
Namespace Name Mixin selector named isConvertedEntryLnet/minecraft/nbt/NbtList;isConvertedEntry(Lnet/minecraft/nbt/NbtCompound;)Zintermediary method_68583Lnet/minecraft/class_2499;method_68583(Lnet/minecraft/class_2487;)Zofficial bLuv;b(Lup;)Z
-
wrapIfNeeded
- Mappings:
Namespace Name Mixin selector named wrapIfNeededLnet/minecraft/nbt/NbtList;wrapIfNeeded(BLnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;intermediary method_68573Lnet/minecraft/class_2499;method_68573(BLnet/minecraft/class_2520;)Lnet/minecraft/class_2520;official aLuv;a(BLvp;)Lvp;
-
convertToCompound
- Mappings:
Namespace Name Mixin selector named convertToCompoundLnet/minecraft/nbt/NbtList;convertToCompound(Lnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtCompound;intermediary method_68584Lnet/minecraft/class_2499;method_68584(Lnet/minecraft/class_2520;)Lnet/minecraft/class_2487;official bLuv;b(Lvp;)Lup;
-
write
Writes the NBT element tooutput.- Specified by:
writein interfaceNbtElement- 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 aLvp;a(Ljava/io/DataOutput;)V
-
getValueType
byte getValueType()- Mappings:
Namespace Name Mixin selector named getValueTypeLnet/minecraft/nbt/NbtList;getValueType()Bintermediary method_68587Lnet/minecraft/class_2499;method_68587()Bofficial eLuv;e()B
-
unwrapAndAdd
- Mappings:
Namespace Name Mixin selector named unwrapAndAddLnet/minecraft/nbt/NbtList;unwrapAndAdd(Lnet/minecraft/nbt/NbtElement;)Vintermediary method_68580Lnet/minecraft/class_2499;method_68580(Lnet/minecraft/class_2520;)Vofficial aLuv;a(Lvp;)V
-
getSizeInBytes
public int getSizeInBytes()- Specified by:
getSizeInBytesin interfaceNbtElement- Mappings:
Namespace Name Mixin selector named getSizeInBytesLnet/minecraft/nbt/NbtElement;getSizeInBytes()Iintermediary method_47988Lnet/minecraft/class_2520;method_47988()Iofficial aLvp;a()I
-
getType
public byte getType()Returns the type of this NBT element.- Specified by:
getTypein interfaceNbtElement- 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 bLvp;b()B
-
getNbtType
Returns the NBT type definition of this NBT element.- Specified by:
getNbtTypein interfaceNbtElement- 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 cLvp;c()Lvr;
-
toString
- Specified by:
toStringin interfaceNbtElement- Overrides:
toStringin classAbstractCollection<NbtElement>
-
remove
- Specified by:
removein interfaceAbstractNbtList- Specified by:
removein interfaceList<NbtElement>- Overrides:
removein classAbstractList<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_10536Luv;method_10536(I)Lvp;
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceAbstractNbtList- 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)Ljava/util/Optional;intermediary method_10602Lnet/minecraft/class_2499;method_10602(I)Ljava/util/Optional;official aLuv;a(I)Ljava/util/Optional;
-
getCompoundOrEmpty
- Mappings:
Namespace Name Mixin selector named getCompoundOrEmptyLnet/minecraft/nbt/NbtList;getCompoundOrEmpty(I)Lnet/minecraft/nbt/NbtCompound;intermediary method_68582Lnet/minecraft/class_2499;method_68582(I)Lnet/minecraft/class_2487;official bLuv;b(I)Lup;
-
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)Ljava/util/Optional;intermediary method_10603Lnet/minecraft/class_2499;method_10603(I)Ljava/util/Optional;official eLuv;e(I)Ljava/util/Optional;
-
getListOrEmpty
- Mappings:
Namespace Name Mixin selector named getListOrEmptyLnet/minecraft/nbt/NbtList;getListOrEmpty(I)Lnet/minecraft/nbt/NbtList;intermediary method_68588Lnet/minecraft/class_2499;method_68588(I)Lnet/minecraft/class_2499;official fLuv;f(I)Luv;
-
getShort
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)Ljava/util/Optional;intermediary method_10609Lnet/minecraft/class_2499;method_10609(I)Ljava/util/Optional;official gLuv;g(I)Ljava/util/Optional;
-
getShort
public short getShort(int index, short fallback) - Mappings:
Namespace Name Mixin selector named getShortLnet/minecraft/nbt/NbtList;getShort(IS)Sintermediary method_68578Lnet/minecraft/class_2499;method_68578(IS)Sofficial aLuv;a(IS)S
-
getInt
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)Ljava/util/Optional;intermediary method_10600Lnet/minecraft/class_2499;method_10600(I)Ljava/util/Optional;official hLuv;h(I)Ljava/util/Optional;
-
getInt
public int getInt(int index, int fallback) - Mappings:
Namespace Name Mixin selector named getIntLnet/minecraft/nbt/NbtList;getInt(II)Iintermediary method_68576Lnet/minecraft/class_2499;method_68576(II)Iofficial aLuv;a(II)I
-
getIntArray
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)Ljava/util/Optional;intermediary method_36111Lnet/minecraft/class_2499;method_36111(I)Ljava/util/Optional;official iLuv;i(I)Ljava/util/Optional;
-
getLongArray
Returns the long array atindex, or an empty long 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 long 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)Ljava/util/Optional;intermediary method_36112Lnet/minecraft/class_2499;method_36112(I)Ljava/util/Optional;official jLuv;j(I)Ljava/util/Optional;
-
getDouble
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)Ljava/util/Optional;intermediary method_10611Lnet/minecraft/class_2499;method_10611(I)Ljava/util/Optional;official kLuv;k(I)Ljava/util/Optional;
-
getDouble
public double getDouble(int index, double fallback) - Mappings:
Namespace Name Mixin selector named getDoubleLnet/minecraft/nbt/NbtList;getDouble(ID)Dintermediary method_68574Lnet/minecraft/class_2499;method_68574(ID)Dofficial aLuv;a(ID)D
-
getFloat
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)Ljava/util/Optional;intermediary method_10604Lnet/minecraft/class_2499;method_10604(I)Ljava/util/Optional;official lLuv;l(I)Ljava/util/Optional;
-
getFloat
public float getFloat(int index, float fallback) - Mappings:
Namespace Name Mixin selector named getFloatLnet/minecraft/nbt/NbtList;getFloat(IF)Fintermediary method_68575Lnet/minecraft/class_2499;method_68575(IF)Fofficial aLuv;a(IF)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/util/Optional;intermediary method_10608Lnet/minecraft/class_2499;method_10608(I)Ljava/util/Optional;official mLuv;m(I)Ljava/util/Optional;
-
getString
- Mappings:
Namespace Name Mixin selector named getStringLnet/minecraft/nbt/NbtList;getString(ILjava/lang/String;)Ljava/lang/String;intermediary method_68577Lnet/minecraft/class_2499;method_68577(ILjava/lang/String;)Ljava/lang/String;official aLuv;a(ILjava/lang/String;)Ljava/lang/String;
-
getNullable
- Mappings:
Namespace Name Mixin selector named getNullableLnet/minecraft/nbt/NbtList;getNullable(I)Lnet/minecraft/nbt/NbtElement;intermediary method_68590Lnet/minecraft/class_2499;method_68590(I)Lnet/minecraft/class_2520;official nLuv;n(I)Lvp;
-
getOptional
- Mappings:
Namespace Name Mixin selector named getOptionalLnet/minecraft/nbt/NbtList;getOptional(I)Ljava/util/Optional;intermediary method_68591Lnet/minecraft/class_2499;method_68591(I)Ljava/util/Optional;official oLuv;o(I)Ljava/util/Optional;
-
size
public int size()- Specified by:
sizein interfaceAbstractNbtList- Specified by:
sizein interfaceCollection<NbtElement>- Specified by:
sizein interfaceList<NbtElement>- Specified by:
sizein classAbstractCollection<NbtElement>
-
get
- Specified by:
getin interfaceAbstractNbtList- 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 method_10534Luv;method_10534(I)Lvp;
-
set
- Specified by:
setin interfaceList<NbtElement>- Overrides:
setin classAbstractList<NbtElement>- Mappings:
Namespace Name Mixin selector named setLnet/minecraft/nbt/NbtList;set(ILnet/minecraft/nbt/NbtElement;)Lnet/minecraft/nbt/NbtElement;intermediary method_68585Lnet/minecraft/class_2499;method_68585(ILnet/minecraft/class_2520;)Lnet/minecraft/class_2520;official cLuv;c(ILvp;)Lvp;
-
add
- Specified by:
addin interfaceList<NbtElement>- Overrides:
addin classAbstractList<NbtElement>- Mappings:
Namespace Name Mixin selector named addLnet/minecraft/nbt/NbtList;add(ILnet/minecraft/nbt/NbtElement;)Vintermediary method_68586Lnet/minecraft/class_2499;method_68586(ILnet/minecraft/class_2520;)Vofficial dLuv;d(ILvp;)V
-
setElement
Sets the element atindextoelement. Does nothing if the types were incompatible.- Specified by:
setElementin interfaceAbstractNbtList- 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 aLuo;a(ILvp;)Z
-
addElement
Insertselementatindex. Does nothing if the types were incompatible.- Specified by:
addElementin interfaceAbstractNbtList- 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 bLuo;b(ILvp;)Z
-
copy
Description copied from interface:NbtElementReturns an NBT element of equal value that won't change with this element.- Specified by:
copyin interfaceNbtElement- 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 gLuv;g()Luv;
-
asNbtList
- Specified by:
asNbtListin interfaceNbtElement- Mappings:
Namespace Name Mixin selector named asNbtListLnet/minecraft/nbt/NbtElement;asNbtList()Ljava/util/Optional;intermediary method_68592Lnet/minecraft/class_2520;method_68592()Ljava/util/Optional;official v_Lvp;v_()Ljava/util/Optional;
-
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 equalsLuv;equals(Ljava/lang/Object;)Z
-
hashCode
public int hashCode()- Specified by:
hashCodein interfaceCollection<NbtElement>- Specified by:
hashCodein interfaceList<NbtElement>- Overrides:
hashCodein classAbstractList<NbtElement>
-
stream
- Specified by:
streamin interfaceAbstractNbtList- Specified by:
streamin interfaceCollection<NbtElement>
-
streamCompounds
- Mappings:
Namespace Name Mixin selector named streamCompoundsLnet/minecraft/nbt/NbtList;streamCompounds()Ljava/util/stream/Stream;intermediary method_68589Lnet/minecraft/class_2499;method_68589()Ljava/util/stream/Stream;official jLuv;j()Ljava/util/stream/Stream;
-
accept
- Specified by:
acceptin interfaceNbtElement- 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 aLvp;a(Lvt;)V
-
clear
public void clear()- Specified by:
clearin interfaceAbstractNbtList- Specified by:
clearin interfaceCollection<NbtElement>- Specified by:
clearin interfaceList<NbtElement>- Overrides:
clearin classAbstractList<NbtElement>
-
doAccept
- Specified by:
doAcceptin interfaceNbtElement- 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 aLvp;a(Lvm;)Lvm$b;
-