类 AttachmentType<T>
IAttachmentHolder
.
Data attachment types must be registered to the registry
.
BlockEntity
-exclusive behavior:
- Modifications to attachments should be followed by a call to
BlockEntity.setChanged()
.
Entity
-exclusive behavior:
- Serializable entity attachments are not copied on death by default (but they are copied when returning from the end).
- Serializable entity attachments can opt into copying on death via
AttachmentType.Builder.copyOnDeath()
.
ItemStack
-exclusive behavior:
- Serializable item stack attachments are synced between the server and the client.
- Serializable item stack attachments are copied when an item stack is copied.
- Serializable item stack attachments must match for item stack comparison to succeed.
Level
-exclusive behavior:
- (nothing)
ChunkAccess
-exclusive behavior:
- Modifications to attachments should be followed by a call to
引用无效
ChunkAccess#setUnsaved(boolean)
- Serializable attachments are copied from a
ProtoChunk
to aLevelChunk
on promotion.
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明(专用程序包) final IAttachmentCopyHandler
<T> (专用程序包) final boolean
(专用程序包) final Function
<IAttachmentHolder, T> (专用程序包) final @Nullable IAttachmentSerializer
<T> -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static <T> AttachmentType.Builder
<T> builder
(Function<IAttachmentHolder, T> defaultValueConstructor) Creates a builder for an attachment type.static <T> AttachmentType.Builder
<T> Creates a builder for an attachment type.private static <T> IAttachmentCopyHandler
<T> defaultCopyHandler
(@Nullable IAttachmentSerializer<T> serializer) static <T extends ValueIOSerializable>
AttachmentType.Builder<T> serializable
(Function<IAttachmentHolder, T> defaultValueConstructor) Create a builder for an attachment type that usesValueIOSerializable
for serialization.static <T extends ValueIOSerializable>
AttachmentType.Builder<T> serializable
(Supplier<T> defaultValueSupplier) Create a builder for an attachment type that usesValueIOSerializable
for serialization.
-
字段详细资料
-
defaultValueSupplier
-
serializer
-
copyOnDeath
final boolean copyOnDeath -
copyHandler
-
-
构造器详细资料
-
AttachmentType
-
-
方法详细资料
-
defaultCopyHandler
private static <T> IAttachmentCopyHandler<T> defaultCopyHandler(@Nullable @Nullable IAttachmentSerializer<T> serializer) -
builder
Creates a builder for an attachment type.See
builder(Function)
for attachments that want to capture a reference to their holder.- 参数:
defaultValueSupplier
- A supplier for a new default value of this attachment type.
-
builder
public static <T> AttachmentType.Builder<T> builder(Function<IAttachmentHolder, T> defaultValueConstructor) Creates a builder for an attachment type.This overload allows capturing a reference to the
IAttachmentHolder
for the attachment. To obtain a specific subtype, the holder can be cast. If the holder is of the wrong type, the constructor should throw an exception. Seebuilder(Supplier)
for an overload that does not capture the holder.- 参数:
defaultValueConstructor
- A constructor for a new default value of this attachment type.
-
serializable
public static <T extends ValueIOSerializable> AttachmentType.Builder<T> serializable(Supplier<T> defaultValueSupplier) Create a builder for an attachment type that usesValueIOSerializable
for serialization. Other kinds of serialization can be implemented usingbuilder(Supplier)
andAttachmentType.Builder.serialize(IAttachmentSerializer)
.See
serializable(Function)
for attachments that want to capture a reference to their holder. -
serializable
public static <T extends ValueIOSerializable> AttachmentType.Builder<T> serializable(Function<IAttachmentHolder, T> defaultValueConstructor) Create a builder for an attachment type that usesValueIOSerializable
for serialization. Other kinds of serialization can be implemented usingbuilder(Supplier)
andAttachmentType.Builder.serialize(IAttachmentSerializer)
.This overload allows capturing a reference to the
IAttachmentHolder
for the attachment. To obtain a specific subtype, the holder can be cast. If the holder is of the wrong type, the constructor should throw an exception. Seeserializable(Supplier)
for an overload that does not capture the holder.
-