类 AttachmentType<T>

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentType<T>

public final class AttachmentType<T> extends Object
Represents a data attachment type: some data that can be added to any object implementing IAttachmentHolder.

Data attachment types must be registered to the registry.

BlockEntity-exclusive behavior:

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 a LevelChunk on promotion.