类 AttachmentType.Builder<T>

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentType.Builder<T>
封闭类:
AttachmentType<T>

public static class AttachmentType.Builder<T> extends Object
  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • serialize

      public AttachmentType.Builder<T> serialize(IAttachmentSerializer<T> serializer)
      Requests that this attachment be persisted to disk (on the logical server side).
      参数:
      serializer - The serializer to use.
    • serialize

      public AttachmentType.Builder<T> serialize(com.mojang.serialization.MapCodec<T> codec)
      Requests that this attachment be persisted to disk (on the logical server side), using a Codec.

      Using a Codec to serialize attachments is discouraged for item stack attachments, for performance reasons. Prefer one of the other options.

      Codec-based attachments cannot capture a reference to their holder.

      参数:
      codec - The codec to use.
    • serialize

      public AttachmentType.Builder<T> serialize(com.mojang.serialization.MapCodec<T> codec, Predicate<? super T> shouldSerialize)
      Requests that this attachment be persisted to disk (on the logical server side), using a Codec.

      Using a Codec to serialize attachments is discouraged for item stack attachments, for performance reasons. Prefer one of the other options.

      Codec-based attachments cannot capture a reference to their holder.

      参数:
      codec - The codec to use.
      shouldSerialize - A check that determines whether serialization of the attachment should occur.
    • copyOnDeath

      public AttachmentType.Builder<T> copyOnDeath()
      Requests that this attachment be persisted when a player respawns or when a living entity is converted.
    • copyHandler

      public AttachmentType.Builder<T> copyHandler(IAttachmentCopyHandler<T> cloner)
      Overrides the copyHandler for this attachment type.

      The default copyHandler serializes the attachment and deserializes it again.

      A copyHandler can only be provided for serializable attachments.

    • build

      public AttachmentType<T> build()