Class Attachment.Builder<T>
java.lang.Object
net.ixdarklord.coolcatcore.api.attachment.Attachment.Builder<T>
- Enclosing class:
- Attachment<T>
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates the attachment and adds it to its registry.Keeps a player's value through death (it's always kept through dimension changes and the End exit).Keeps a block entity's value in the item it drops as, and restores it when that item is placed (like a shulker box's contents).networkCodec(StreamCodec<? super net.minecraft.network.FriendlyByteBuf, T> streamCodec) How values are written to the network.onChange(Attachment.Listener<T> listener) sync(SyncPolicy policy) Sends the value to clients: whenever it changes (once per tick at most, only what changed), and in full when a player starts seeing the holder, joins, respawns or changes dimension.
-
Method Details
-
networkCodec
public Attachment.Builder<T> networkCodec(StreamCodec<? super net.minecraft.network.FriendlyByteBuf, T> streamCodec) How values are written to the network. Persistent keys don't need one: their codec is used (through NBT), but a dedicated stream codec is smaller and faster for values that change often. -
sync
Sends the value to clients: whenever it changes (once per tick at most, only what changed), and in full when a player starts seeing the holder, joins, respawns or changes dimension. -
copyOnDeath
Keeps a player's value through death (it's always kept through dimension changes and the End exit). -
keepOnDrop
Keeps a block entity's value in the item it drops as, and restores it when that item is placed (like a shulker box's contents). The block's loot table must copy the value from the block entity into the item'sBlockEntityTag: addAttachmentRegistry.copyKeptOnDrop()to it (acopy_nbtfunction). -
onChange
-
build
Creates the attachment and adds it to its registry.
-