Class CompoundTag

java.lang.Object
net.minecraft.nbt.CompoundTag
All Implemented Interfaces:
Tag

public final class CompoundTag extends Object implements Tag
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • CODEC

      public static final com.mojang.serialization.Codec<CompoundTag> 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

      public static final TagType<CompoundTag> TYPE
    • tags

      private final Map<String,Tag> tags
  • Constructor Details

    • CompoundTag

      CompoundTag(Map<String,Tag> tags)
    • 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

      public void write(DataOutput output) throws IOException
      Specified by:
      write in interface Tag
      Throws:
      IOException
    • sizeInBytes

      public int sizeInBytes()
      Specified by:
      sizeInBytes in interface Tag
    • keySet

      public Set<String> keySet()
    • entrySet

      public Set<Map.Entry<String,Tag>> entrySet()
    • values

      public Collection<Tag> values()
    • forEach

      public void forEach(BiConsumer<String,Tag> consumer)
    • getId

      public byte getId()
      Specified by:
      getId in interface Tag
    • getType

      public TagType<CompoundTag> getType()
      Specified by:
      getType in interface Tag
    • size

      public int size()
    • put

      public @Nullable Tag put(String name, Tag tag)
    • putByte

      public void putByte(String name, byte value)
    • putShort

      public void putShort(String name, short value)
    • putInt

      public void putInt(String name, int value)
    • putLong

      public void putLong(String name, long value)
    • putFloat

      public void putFloat(String name, float value)
    • putDouble

      public void putDouble(String name, double value)
    • putString

      public void putString(String name, String value)
    • putByteArray

      public void putByteArray(String name, byte[] value)
    • putIntArray

      public void putIntArray(String name, int[] value)
    • putLongArray

      public void putLongArray(String name, long[] value)
    • putBoolean

      public void putBoolean(String name, boolean value)
    • get

      public @Nullable Tag get(String name)
    • contains

      public boolean contains(String name)
    • getOptional

      private Optional<Tag> getOptional(String name)
    • getByte

      public Optional<Byte> getByte(String name)
    • getByteOr

      public byte getByteOr(String name, byte defaultValue)
    • getShort

      public Optional<Short> getShort(String name)
    • getShortOr

      public short getShortOr(String name, short defaultValue)
    • getInt

      public Optional<Integer> getInt(String name)
    • getIntOr

      public int getIntOr(String name, int defaultValue)
    • getLong

      public Optional<Long> getLong(String name)
    • getLongOr

      public long getLongOr(String name, long defaultValue)
    • getFloat

      public Optional<Float> getFloat(String name)
    • getFloatOr

      public float getFloatOr(String name, float defaultValue)
    • getDouble

      public Optional<Double> getDouble(String name)
    • getDoubleOr

      public double getDoubleOr(String name, double defaultValue)
    • getString

      public Optional<String> getString(String name)
    • getStringOr

      public String getStringOr(String name, String defaultValue)
    • getByteArray

      public Optional<byte[]> getByteArray(String name)
    • getIntArray

      public Optional<int[]> getIntArray(String name)
    • getLongArray

      public Optional<long[]> getLongArray(String name)
    • getCompound

      public Optional<CompoundTag> getCompound(String name)
    • getCompoundOrEmpty

      public CompoundTag getCompoundOrEmpty(String name)
    • getList

      public Optional<ListTag> getList(String name)
    • getListOrEmpty

      public ListTag getListOrEmpty(String name)
    • getBoolean

      public Optional<Boolean> getBoolean(String name)
    • getBooleanOr

      public boolean getBooleanOr(String string, boolean defaultValue)
    • remove

      public @Nullable Tag remove(String name)
    • toString

      public String toString()
      Specified by:
      toString in interface Tag
      Overrides:
      toString in class Object
    • isEmpty

      public boolean isEmpty()
    • shallowCopy

      protected CompoundTag shallowCopy()
    • copy

      public CompoundTag copy()
      Specified by:
      copy in interface Tag
    • asCompound

      public Optional<CompoundTag> asCompound()
      Specified by:
      asCompound in interface Tag
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeNamedTag

      private static void writeNamedTag(String name, Tag tag, DataOutput output) throws IOException
      Throws:
      IOException
    • readNamedTagData

      private static Tag readNamedTagData(TagType<?> type, String name, DataInput input, NbtAccounter accounter)
    • merge

      public CompoundTag merge(CompoundTag other)
      Copies all the tags of other into this tag, then returns itself.
      See Also:
    • accept

      public void accept(TagVisitor visitor)
      Specified by:
      accept in interface Tag
    • accept

      Specified by:
      accept in interface Tag
    • store

      public <T> void store(String name, com.mojang.serialization.Codec<T> codec, T value)
    • storeNullable

      public <T> void storeNullable(String name, com.mojang.serialization.Codec<T> codec, @Nullable T value)
    • store

      public <T> void store(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, T value)
    • storeNullable

      public <T> void storeNullable(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops, @Nullable T value)
    • 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

      public <T> Optional<T> read(String name, com.mojang.serialization.Codec<T> codec)
    • read

      public <T> Optional<T> read(String name, com.mojang.serialization.Codec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops)
    • read

      public <T> Optional<T> read(com.mojang.serialization.MapCodec<T> codec)
    • read

      public <T> Optional<T> read(com.mojang.serialization.MapCodec<T> codec, com.mojang.serialization.DynamicOps<Tag> ops)