Package net.minecraft.nbt
Class CompoundTag
java.lang.Object
net.minecraft.nbt.CompoundTag
- All Implemented Interfaces:
Tag
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.Codec<CompoundTag> private static final org.slf4j.Loggerprivate static final intprivate static final intstatic final TagType<CompoundTag> Fields inherited from interface net.minecraft.nbt.Tag
ARRAY_HEADER, MAX_DEPTH, OBJECT_HEADER, OBJECT_REFERENCE, STRING_SIZE, TAG_BYTE, TAG_BYTE_ARRAY, TAG_COMPOUND, TAG_DOUBLE, TAG_END, TAG_FLOAT, TAG_INT, TAG_INT_ARRAY, TAG_LIST, TAG_LONG, TAG_LONG_ARRAY, TAG_SHORT, TAG_STRING -
Constructor Summary
ConstructorsConstructorDescriptionCompoundTag(int expectedEntries) Neo: create a compound tag that is generally suitable to hold the given amount of entries without needing to resize the internal map.CompoundTag(Map<String, Tag> tags) -
Method Summary
Modifier and TypeMethodDescriptionaccept(StreamTagVisitor p_197442_) voidaccept(TagVisitor p_177857_) booleancopy()entrySet()booleanvoidforEach(BiConsumer<String, Tag> action) getBoolean(String key) booleangetBooleanOr(String key, boolean defaultValue) Optional<byte[]> getByteArray(String key) bytegetCompound(String key) getCompoundOrEmpty(String key) doublegetDoubleOr(String key, double defaultValue) floatgetFloatOr(String key, float defaultValue) bytegetId()Optional<int[]> getIntArray(String key) intgetListOrEmpty(String key) Optional<long[]> getLongArray(String key) longgetOptional(String key) shortgetShortOr(String key, short defaultValue) getStringOr(String key, String defaultValue) getType()inthashCode()booleanisEmpty()keySet()merge(CompoundTag other) Copies all the tags ofotherinto this tag, then returns itself.voidputBoolean(String key, boolean value) voidvoidputByteArray(String key, byte[] value) voidvoidvoidvoidputIntArray(String key, int[] value) voidvoidputLongArray(String key, long[] value) voidvoid<T> Optional<T> read(com.mojang.serialization.MapCodec<T> mapCodec) <T> Optional<T> <T> Optional<T> <T> Optional<T> read(String key, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops) (package private) static TagreadNamedTagData(TagType<?> type, String name, DataInput input, NbtAccounter accounter) voidprotected CompoundTagintsize()int<T> voidstore(com.mojang.serialization.MapCodec<T> mapCodec, com.mojang.serialization.DynamicOps<Tag> ops, T data) <T> voidstore(com.mojang.serialization.MapCodec<T> mapCodec, T data) <T> voidstore(String key, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T data) <T> void<T> voidstoreNullable(String key, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T data) <T> voidstoreNullable(String key, com.mojang.serialization.Codec<T> codec, T data) toString()values()voidwrite(DataOutput output) private static voidwriteNamedTag(String name, Tag tag, DataOutput output) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.minecraft.nbt.Tag
acceptAsRoot, asBoolean, asByte, asByteArray, asDouble, asFloat, asInt, asIntArray, asList, asLong, asLongArray, asNumber, asShort, asString
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CODEC
-
SELF_SIZE_IN_BYTES
private static final int SELF_SIZE_IN_BYTES- See Also:
-
MAP_ENTRY_SIZE_IN_BYTES
private static final int MAP_ENTRY_SIZE_IN_BYTES- See Also:
-
TYPE
-
tags
-
-
Constructor Details
-
CompoundTag
-
CompoundTag
public CompoundTag() -
CompoundTag
public CompoundTag(int expectedEntries) Neo: create a compound tag that is generally suitable to hold the given amount of entries without needing to resize the internal map.- Parameters:
expectedEntries- the expected number of entries that the compound tag will have- See Also:
-
-
Method Details
-
write
- Specified by:
writein interfaceTag- Throws:
IOException
-
sizeInBytes
public int sizeInBytes()- Specified by:
sizeInBytesin interfaceTag
-
keySet
-
entrySet
-
values
-
forEach
-
getId
public byte getId() -
getType
-
size
public int size() -
put
-
putByte
-
putShort
-
putInt
-
putLong
-
putFloat
-
putDouble
-
putString
-
putByteArray
-
putIntArray
-
putLongArray
-
putBoolean
-
get
-
contains
-
getOptional
-
getByte
-
getByteOr
-
getShort
-
getShortOr
-
getInt
-
getIntOr
-
getLong
-
getLongOr
-
getFloat
-
getFloatOr
-
getDouble
-
getDoubleOr
-
getString
-
getStringOr
-
getByteArray
-
getIntArray
-
getLongArray
-
getCompound
-
getCompoundOrEmpty
-
getList
-
getListOrEmpty
-
getBoolean
-
getBooleanOr
-
remove
-
toString
-
isEmpty
public boolean isEmpty() -
shallowCopy
-
copy
-
asCompound
- Specified by:
asCompoundin interfaceTag
-
equals
-
hashCode
public int hashCode() -
writeNamedTag
- Throws:
IOException
-
readNamedTagData
-
merge
Copies all the tags ofotherinto this tag, then returns itself.- See Also:
-
accept
-
accept
-
store
-
storeNullable
public <T> void storeNullable(String key, com.mojang.serialization.Codec<T> codec, @Nullable T data) -
store
-
storeNullable
-
store
public <T> void store(com.mojang.serialization.MapCodec<T> mapCodec, T data) -
store
public <T> void store(com.mojang.serialization.MapCodec<T> mapCodec, com.mojang.serialization.DynamicOps<Tag> ops, T data) -
read
-
read
-
read
-
read
-