类 AttachmentType.Builder<T>
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentType.Builder<T>
- 封闭类:
AttachmentType<T>
-
字段概要
字段修饰符和类型字段说明private @Nullable IAttachmentCopyHandler
<T> private boolean
private final Function
<IAttachmentHolder, T> private @Nullable IAttachmentSerializer
<T> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明build()
copyHandler
(IAttachmentCopyHandler<T> cloner) Overrides the copyHandler for this attachment type.Requests that this attachment be persisted when a player respawns or when a living entity is converted.Requests that this attachment be persisted to disk (on the logical server side), using aCodec
.Requests that this attachment be persisted to disk (on the logical server side), using aCodec
.serialize
(IAttachmentSerializer<T> serializer) Requests that this attachment be persisted to disk (on the logical server side).
-
字段详细资料
-
defaultValueSupplier
-
serializer
-
copyOnDeath
private boolean copyOnDeath -
copyHandler
-
-
构造器详细资料
-
Builder
-
-
方法详细资料
-
serialize
Requests that this attachment be persisted to disk (on the logical server side).- 参数:
serializer
- The serializer to use.
-
serialize
Requests that this attachment be persisted to disk (on the logical server side), using aCodec
.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 aCodec
.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
Requests that this attachment be persisted when a player respawns or when a living entity is converted. -
copyHandler
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
-