Package net.minecraft.nbt
Class NbtCompound
java.lang.Object
net.minecraft.nbt.NbtCompound
- All Implemented Interfaces:
NbtElement
public class NbtCompound extends Object implements NbtElement
Represents an NBT compound object which holds unordered key-value pairs with distinct case-sensitive string keys.
-
Field Summary
Fields Modifier and Type Field Description static com.mojang.serialization.Codec<NbtCompound>CODECprivate Map<String,NbtElement>entriesprivate static LoggerLOGGERprivate static PatternPATTERNstatic NbtType<NbtCompound>TYPEFields inherited from interface net.minecraft.nbt.NbtElement
AQUA, GOLD, GREEN, RED -
Constructor Summary
Constructors Modifier Constructor Description NbtCompound()protectedNbtCompound(Map<String,NbtElement> entries) -
Method Summary
Modifier and Type Method Description booleancontains(String key)Determines whether the NBT compound object contains the specified key.booleancontains(String key, int type)Returns whether the NBT compound object contains an element of the specified type at the specified key.booleancontainsUuid(String key)Returnstrueif thisNbtCompoundcontains a valid UUID representation associated with the given key.NbtCompoundcopy()Copies this NBT element.NbtCompoundcopyFrom(NbtCompound source)private CrashReportcreateCrashReport(String key, NbtType<?> reader, ClassCastException classCastException)booleanequals(Object o)protected static StringescapeTagKey(String key)NbtElementget(String key)booleangetBoolean(String key)bytegetByte(String key)byte[]getByteArray(String key)NbtCompoundgetCompound(String key)doublegetDouble(String key)floatgetFloat(String key)intgetInt(String key)int[]getIntArray(String key)Set<String>getKeys()NbtListgetList(String key, int type)longgetLong(String key)long[]getLongArray(String key)NbtType<NbtCompound>getNbtType()Gets the NBT type definition of this NBT element.shortgetShort(String key)intgetSize()StringgetString(String key)bytegetType()Gets the type of this NBT element.bytegetType(String key)Gets the NBT type of the element stored at the specified key.UUIDgetUuid(String key)Reads aUUIDfrom its NBT representation in thisNbtCompound.inthashCode()booleanisEmpty()protected static TextprettyPrintTagKey(String key)NbtElementput(String key, NbtElement element)voidputBoolean(String key, boolean value)voidputByte(String key, byte value)voidputByteArray(String key, byte[] value)voidputDouble(String key, double value)voidputFloat(String key, float value)voidputInt(String key, int value)voidputIntArray(String key, int[] value)voidputIntArray(String key, List<Integer> value)voidputLong(String key, long value)voidputLongArray(String key, long[] value)voidputLongArray(String key, List<Long> value)voidputShort(String key, short value)voidputString(String key, String value)voidputUuid(String key, UUID value)Writes aUUIDto its NBT representation in thisNbtCompound.private static NbtElementread(NbtType<?> reader, String key, DataInput input, int depth, NbtTagSizeTracker tracker)private static bytereadByte(DataInput input, NbtTagSizeTracker tracker)private static StringreadString(DataInput input, NbtTagSizeTracker tracker)voidremove(String key)protected Map<String,NbtElement>toMap()StringtoString()TexttoText(String indent, int depth)voidwrite(DataOutput output)private static voidwrite(String key, NbtElement element, DataOutput output)Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.nbt.NbtElement
asString, toText
-
Field Details
-
CODEC
-
LOGGER
-
PATTERN
-
TYPE
-
entries
-
-
Constructor Details
-
NbtCompound
-
NbtCompound
public NbtCompound()
-
-
Method Details
-
write
- Specified by:
writein interfaceNbtElement- Throws:
IOException
-
getKeys
-
getType
public byte getType()Gets the type of this NBT element.- Specified by:
getTypein interfaceNbtElement- Returns:
- the type
-
getNbtType
Gets the NBT type definition of this NBT element.- Specified by:
getNbtTypein interfaceNbtElement- Returns:
- the element type definition
-
getSize
public int getSize() -
put
-
putByte
-
putShort
-
putInt
-
putLong
-
putUuid
Writes aUUIDto its NBT representation in thisNbtCompound. -
getUuid
Reads aUUIDfrom its NBT representation in thisNbtCompound. -
containsUuid
Returnstrueif thisNbtCompoundcontains a valid UUID representation associated with the given key. A valid UUID is represented by an int array of length 4. -
putFloat
-
putDouble
-
putString
-
putByteArray
-
putIntArray
-
putIntArray
-
putLongArray
-
putLongArray
-
putBoolean
-
get
-
getType
Gets the NBT type of the element stored at the specified key.- Returns:
- the element NBT type, or
0if it does not exist
-
contains
Determines whether the NBT compound object contains the specified key.- Returns:
trueif the key exists, elsefalse
-
contains
Returns whether the NBT compound object contains an element of the specified type at the specified key.The type restriction can also be
99, which only allows any type of number.- Returns:
trueif the key exists and the element type is equivalent to the giventype, elsefalse
-
getByte
-
getShort
-
getInt
-
getLong
-
getFloat
-
getDouble
-
getString
-
getByteArray
-
getIntArray
-
getLongArray
-
getCompound
-
getList
-
getBoolean
-
remove
-
toString
- Specified by:
toStringin interfaceNbtElement- Overrides:
toStringin classObject
-
isEmpty
public boolean isEmpty() -
createCrashReport
private CrashReport createCrashReport(String key, NbtType<?> reader, ClassCastException classCastException) -
copy
Description copied from interface:NbtElementCopies this NBT element.- Specified by:
copyin interfaceNbtElement- Returns:
- the copied element
-
equals
-
hashCode
public int hashCode() -
write
- Throws:
IOException
-
readByte
- Throws:
IOException
-
readString
- Throws:
IOException
-
read
private static NbtElement read(NbtType<?> reader, String key, DataInput input, int depth, NbtTagSizeTracker tracker) -
copyFrom
-
escapeTagKey
-
prettyPrintTagKey
-
toText
- Specified by:
toTextin interfaceNbtElement
-
toMap
-