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 pVisitor)
      Specified by:
      accept in interface Tag
    • accept

      Specified by:
      accept in interface Tag
    • store

      public <T> void store(String p_401096_, com.mojang.serialization.Codec<T> p_401071_, T p_401333_)
    • storeNullable

      public <T> void storeNullable(String p_405110_, com.mojang.serialization.Codec<T> p_405799_, @Nullable T p_405604_)
    • store

      public <T> void store(String p_401002_, com.mojang.serialization.Codec<T> p_401379_, com.mojang.serialization.DynamicOps<Tag> p_401063_, T p_401119_)
    • storeNullable

      public <T> void storeNullable(String p_404778_, com.mojang.serialization.Codec<T> p_405437_, com.mojang.serialization.DynamicOps<Tag> p_405108_, @Nullable T p_405353_)
    • store

      public <T> void store(com.mojang.serialization.MapCodec<T> p_401258_, T p_401416_)
    • store

      public <T> void store(com.mojang.serialization.MapCodec<T> p_401165_, com.mojang.serialization.DynamicOps<Tag> p_401224_, T p_401226_)
    • read

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

      public <T> Optional<T> read(String p_401362_, com.mojang.serialization.Codec<T> p_401434_, com.mojang.serialization.DynamicOps<Tag> p_401431_)
    • read

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

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