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 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 visitor) voidaccept(TagVisitor visitor) booleancopy()entrySet()booleanvoidforEach(BiConsumer<String, Tag> consumer) @Nullable TaggetBoolean(String name) booleangetBooleanOr(String string, boolean defaultValue) Optional<byte[]> getByteArray(String name) bytegetCompound(String name) getCompoundOrEmpty(String name) doublegetDoubleOr(String name, double defaultValue) floatgetFloatOr(String name, float defaultValue) bytegetId()Optional<int[]> getIntArray(String name) intgetListOrEmpty(String name) Optional<long[]> getLongArray(String name) longgetOptional(String name) shortgetShortOr(String name, short defaultValue) getStringOr(String name, String defaultValue) getType()inthashCode()booleanisEmpty()keySet()merge(CompoundTag other) Copies all the tags ofotherinto this tag, then returns itself.@Nullable TagvoidputBoolean(String name, boolean value) voidvoidputByteArray(String name, byte[] value) voidvoidvoidvoidputIntArray(String name, int[] value) voidvoidputLongArray(String name, long[] value) voidvoid<T> Optional<T> read(com.mojang.serialization.MapCodec<T> codec) <T> Optional<T> <T> Optional<T> <T> Optional<T> read(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops) private static TagreadNamedTagData(TagType<?> type, String name, DataInput input, NbtAccounter accounter) @Nullable Tagprotected CompoundTagintsize()int<T> voidstore(com.mojang.serialization.MapCodec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T value) <T> voidstore(com.mojang.serialization.MapCodec<T> codec, T value) <T> voidstore(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T value) <T> void<T> voidstoreNullable(String name, com.mojang.serialization.Codec<T> codec, @Nullable T value) <T> voidstoreNullable(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, @Nullable T value) toString()values()voidwrite(DataOutput output) private static voidwriteNamedTag(String name, Tag tag, DataOutput output) Methods inherited from interface 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
-
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
-
writeNamedTag
- Throws:
IOException
-
readNamedTagData
private static Tag readNamedTagData(TagType<?> type, String name, DataInput input, NbtAccounter accounter) -
merge
Copies all the tags ofotherinto this tag, then returns itself.- See Also:
-
accept
-
accept
-
store
-
storeNullable
public <T> void storeNullable(String name, com.mojang.serialization.Codec<T> codec, @Nullable T value) -
store
-
storeNullable
-
store
public <T> void store(com.mojang.serialization.MapCodec<T> codec, T value) -
store
public <T> void store(com.mojang.serialization.MapCodec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T value) -
read
-
read
-
read
-
read
-