Class Attachment.Builder<T>

java.lang.Object
net.ixdarklord.coolcatcore.api.attachment.Attachment.Builder<T>
Enclosing class:
Attachment<T>

public static final class Attachment.Builder<T> extends Object
  • 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

      public Attachment.Builder<T> 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.
    • copyOnDeath

      public Attachment.Builder<T> copyOnDeath()
      Keeps a player's value through death (it's always kept through dimension changes and the End exit).
    • keepOnDrop

      public Attachment.Builder<T> 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>:attachments component from the block entity, e.g. copy_components with "include": ["mymod:attachments"].
    • onChange

      public Attachment.Builder<T> onChange(Attachment.Listener<T> listener)
    • build

      public Attachment<T> build()
      Creates the attachment and adds it to its registry.