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(net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, T> streamCodec) How values are written to the network.onChange(Attachment.Listener<T> listener) Shows a held item being put away and taken out again whenever this value changes on it, as vanilla does for most changes to a held stack.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(net.minecraft.network.codec.StreamCodec<? super net.minecraft.network.RegistryFriendlyByteBuf, 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 its mod's<modid>:attachmentscomponent from the block entity, e.g.copy_componentswith"include": ["mymod:attachments"]. -
swapAnimation
Shows a held item being put away and taken out again whenever this value changes on it, as vanilla does for most changes to a held stack. Without it, attachment changes are quiet: the item stays where it is. -
onChange
-
build
Creates the attachment and adds it to its registry.
-