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> pTags)
    • 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 pOutput) 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> pAction)
    • 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

      @Nullable public Tag put(String pKey, Tag pValue)
    • putByte

      public void putByte(String pKey, byte pValue)
    • putShort

      public void putShort(String pKey, short pValue)
    • putInt

      public void putInt(String pKey, int pValue)
    • putLong

      public void putLong(String pKey, long pValue)
    • putFloat

      public void putFloat(String pKey, float pValue)
    • putDouble

      public void putDouble(String pKey, double pValue)
    • putString

      public void putString(String pKey, String pValue)
    • putByteArray

      public void putByteArray(String pKey, byte[] pValue)
    • putIntArray

      public void putIntArray(String pKey, int[] pValue)
    • putLongArray

      public void putLongArray(String pKey, long[] pValue)
    • putBoolean

      public void putBoolean(String pKey, boolean pValue)
    • get

      @Nullable public Tag get(String pKey)
    • contains

      public boolean contains(String pKey)
    • getOptional

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

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

      public byte getByteOr(String pKey, byte pDefaultValue)
    • getShort

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

      public short getShortOr(String pKey, short pDefaultValue)
    • getInt

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

      public int getIntOr(String pKey, int pDefaultValue)
    • getLong

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

      public long getLongOr(String pKey, long pDefaultValue)
    • getFloat

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

      public float getFloatOr(String pKey, float pDefaultValue)
    • getDouble

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

      public double getDoubleOr(String pKey, double pDefaultValue)
    • getString

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

      public String getStringOr(String pKey, String pDefaultValue)
    • getByteArray

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

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

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

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

      public CompoundTag getCompoundOrEmpty(String pKey)
    • getList

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

      public ListTag getListOrEmpty(String pKey)
    • getBoolean

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

      public boolean getBooleanOr(String pKey, boolean pDefaultValue)
    • remove

      public void remove(String pKey)
    • 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 pOther)
      Overrides:
      equals in class Object
    • hashCode

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

      private static void writeNamedTag(String pName, Tag pTag, DataOutput pOutput) throws IOException
      Throws:
      IOException
    • readNamedTagData

      static Tag readNamedTagData(TagType<?> pType, String pName, DataInput pInput, NbtAccounter pAccounter)
    • merge

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

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

      Specified by:
      accept in interface Tag
    • store

      public <T> void store(String pKey, com.mojang.serialization.Codec<T> pCodec, T pData)
    • storeNullable

      public <T> void storeNullable(String pKey, com.mojang.serialization.Codec<T> pCodec, @Nullable T pData)
    • store

      public <T> void store(String pKey, com.mojang.serialization.Codec<T> pCodec, com.mojang.serialization.DynamicOps<Tag> pOps, T pData)
    • storeNullable

      public <T> void storeNullable(String pKey, com.mojang.serialization.Codec<T> pCodec, com.mojang.serialization.DynamicOps<Tag> pOps, @Nullable T pData)
    • store

      public <T> void store(com.mojang.serialization.MapCodec<T> pMapCodec, T pData)
    • store

      public <T> void store(com.mojang.serialization.MapCodec<T> pMapCodec, com.mojang.serialization.DynamicOps<Tag> pOps, T pData)
    • read

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

      public <T> Optional<T> read(String pKey, com.mojang.serialization.Codec<T> pCodec, com.mojang.serialization.DynamicOps<Tag> pOps)
    • read

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

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