Class CompoundObjectTag<T>

java.lang.Object
net.orbyfied.j8.util.nbt.CompoundObjectTag<T>
All Implemented Interfaces:
net.minecraft.nbt.Tag

public class CompoundObjectTag<T> extends Object implements net.minecraft.nbt.Tag
A runtime reference to an object which is converted to a compound tag with the data prefixed by the class name to save it persistently.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The key used to store the class name in the serialized compound tags.
    static final HashMap<Class<?>,CompoundTagSerializer<?>>
    The serializers loaded mapped by class.
    static final String
    The name of the field that compound tag serializable classes should define and initialize with their serializer.
    static final net.minecraft.nbt.TagType<CompoundObjectTag<?>>
    Tag type.

    Fields inherited from interface net.minecraft.nbt.Tag

    ARRAY_HEADER, MAX_DEPTH, OBJECT_HEADER, OBJECT_REFERENCE, STRING_SIZE, TAG_ANY_NUMERIC, 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

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull net.minecraft.nbt.StreamTagVisitor.ValueResult
    accept(net.minecraft.nbt.StreamTagVisitor visitor)
     
    void
    accept(net.minecraft.nbt.TagVisitor visitor)
     
    @NotNull net.minecraft.nbt.Tag
     
    boolean
     
    byte
     
     
     
    @NotNull net.minecraft.nbt.TagType<?>
     
    int
     
    loadFromCompound(net.minecraft.nbt.CompoundTag ctag)
    Tries to load an object from the given compound tag.
    static net.minecraft.nbt.CompoundTag
    saveToCompound(CompoundObjectTag<?> otag, net.minecraft.nbt.CompoundTag ctag)
    Saves the provided compound object tag to the specified compound tag and returns it (the compound tag) back to you.
     
     
    void
    write(DataOutput output)
     
    net.minecraft.nbt.CompoundTag
    Attempts to serialize this object tag into a new compound tag.
    net.minecraft.nbt.CompoundTag
    writeCompoundTag(net.minecraft.nbt.CompoundTag tag)
    Attempts to serialize this object tag into the provided compound tag.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface net.minecraft.nbt.Tag

    acceptAsRoot, getAsString
  • Field Details

    • SERIALIZER_FIELD_NAME

      public static final String SERIALIZER_FIELD_NAME
      The name of the field that compound tag serializable classes should define and initialize with their serializer.
      See Also:
    • CLASS_NAME_TAG

      public static final String CLASS_NAME_TAG
      The key used to store the class name in the serialized compound tags.
      See Also:
    • LOADED_SERIALIZERS

      public static final HashMap<Class<?>,CompoundTagSerializer<?>> LOADED_SERIALIZERS
      The serializers loaded mapped by class. Used mainly as a cache, but can also be used to define or overwrite serializers for other classes.
    • TAG_TYPE

      public static final net.minecraft.nbt.TagType<CompoundObjectTag<?>> TAG_TYPE
      Tag type.
  • Constructor Details

    • CompoundObjectTag

      public CompoundObjectTag(T obj)
  • Method Details

    • loadFromCompound

      public static CompoundObjectTag<?> loadFromCompound(net.minecraft.nbt.CompoundTag ctag)
      Tries to load an object from the given compound tag.
      Parameters:
      ctag - The compound tag to load.
      Returns:
      The object tag or null if it failed.
    • saveToCompound

      public static net.minecraft.nbt.CompoundTag saveToCompound(CompoundObjectTag<?> otag, net.minecraft.nbt.CompoundTag ctag)
      Saves the provided compound object tag to the specified compound tag and returns it (the compound tag) back to you.
      Parameters:
      otag - The object tag to write.
      ctag - The compound tag to write to.
      Returns:
      The (same) compound tag.
    • getObjectType

      public Class<?> getObjectType()
    • getObject

      public T getObject()
    • setObject

      public CompoundObjectTag<T> setObject(T o)
    • writeCompoundTag

      public net.minecraft.nbt.CompoundTag writeCompoundTag(net.minecraft.nbt.CompoundTag tag)
      Attempts to serialize this object tag into the provided compound tag.
      Parameters:
      tag - The output compound tag.
      Returns:
      The output compound tag.
    • writeCompoundTag

      public net.minecraft.nbt.CompoundTag writeCompoundTag()
      Attempts to serialize this object tag into a new compound tag.
      Returns:
      The output compound tag.
      See Also:
    • write

      public void write(DataOutput output) throws IOException
      Specified by:
      write in interface net.minecraft.nbt.Tag
      Throws:
      IOException
    • getId

      public byte getId()
      Specified by:
      getId in interface net.minecraft.nbt.Tag
    • getType

      @NotNull public @NotNull net.minecraft.nbt.TagType<?> getType()
      Specified by:
      getType in interface net.minecraft.nbt.Tag
    • copy

      @NotNull public @NotNull net.minecraft.nbt.Tag copy()
      Specified by:
      copy in interface net.minecraft.nbt.Tag
    • accept

      public void accept(net.minecraft.nbt.TagVisitor visitor)
      Specified by:
      accept in interface net.minecraft.nbt.Tag
    • accept

      public @NotNull net.minecraft.nbt.StreamTagVisitor.ValueResult accept(net.minecraft.nbt.StreamTagVisitor visitor)
      Specified by:
      accept in interface net.minecraft.nbt.Tag
    • toString

      public String toString()
      Specified by:
      toString in interface net.minecraft.nbt.Tag
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object