Interface ITag<T>

Type Parameters:
T - The Object type this tag stores
All Known Subinterfaces:
ICompoundTag, IListTag
All Known Implementing Classes:
Basic_Tag, Collection_Tag, Tag, 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

public interface ITag<T>
Base interface for all NBT (Named Binary Tag) structures. NBT tags are the fundamental building blocks of Minecraft's data format, each carrying a name, type, and payload according to the NBT specification.
Author:
Paul Ferlitz
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Applies a custom transformation or inspection operation to this tag.
    void
    editTag(ITag<?> newTag)
    Replaces this tag's content with data from another compatible tag.
    Returns the actual data payload stored in this tag.
    int
    Returns the NBT type identifier for this tag.
    Returns the name of this tag.
    void
    setData(T data)
    Updates the data payload of this tag.
    void
    Updates the name of this tag.
    Returns a human-readable representation of this tag.
  • Method Details

    • getId

      int getId()
      Returns the NBT type identifier for this tag. Each tag type has a unique ID as defined in the NBT specification.
      Returns:
      The NBT type ID (0-12)
    • getName

      String getName()
      Returns the name of this tag. In NBT format, every tag has a name except the root tag which may have an empty name.
      Returns:
      The tag's name as String
    • setName

      void setName(String name)
      Updates the name of this tag.
      Parameters:
      name - The new tag name
    • getData

      T getData()
      Returns the actual data payload stored in this tag.
      Returns:
      The tag's data of type T
    • setData

      void setData(T data)
      Updates the data payload of this tag.
      Parameters:
      data - The new data to store
    • editTag

      void editTag(ITag<?> newTag)
      Replaces this tag's content with data from another compatible tag. Both tags must be of the same NBT type.
      Parameters:
      newTag - The source tag to copy from
    • applyOperation

      void applyOperation(Consumer<ITag<T>> operation)
      Applies a custom transformation or inspection operation to this tag. Useful for batch operations or complex data processing.
      Parameters:
      operation - The Consumer to apply
    • toString

      String toString()
      Returns a human-readable representation of this tag.
      Overrides:
      toString in class Object
      Returns:
      A formatted string showing the tag's name, type, and data