Interface IAttachmentSerializer<S extends Tag,T>

Type Parameters:
S - A Tag subclass: the serialized representation.
T - The type of the data attachment.

public interface IAttachmentSerializer<S extends Tag,T>
Serializer for data attachments.

The read(IAttachmentHolder, Tag) method must be implemented by subclasses!

  • Method Summary

    Modifier and Type
    Method
    Description
    default T
    read(IAttachmentHolder holder, S tag)
    Reads the attachment from NBT.
    default T
    read(S tag)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Implement read(IAttachmentHolder, Tag) instead.
    write(T attachment)
    Writes the attachment to NBT, or returns null if it is should not be serialized.
  • Method Details

    • read

      @Deprecated(forRemoval=true, since="1.20.4") default T read(S tag)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Implement read(IAttachmentHolder, Tag) instead. This method will be removed in a future version.
    • read

      default T read(IAttachmentHolder holder, S tag)
      Reads the attachment from NBT.

      In a future version, the default implementation will be removed, but for now it exists for backwards compatibility with read(Tag).

      Parameters:
      holder - the holder for the attachment, can be cast if the subtype is known
      tag - the serialized attachment
    • write

      @Nullable S write(T attachment)
      Writes the attachment to NBT, or returns null if it is should not be serialized.