Class AttachmentStore
java.lang.Object
net.ixdarklord.coolcatcore.internal.attachment.AttachmentStore
- All Implemented Interfaces:
AttachmentHolder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet<Attachment<?>> The attachments with a stored value.voidcopyFrom(AttachmentStore other, Predicate<Attachment<?>> filter, net.minecraft.core.HolderLookup.Provider registries) Copies another store's values, deep-copying persistent ones through their codec.<T> Tget(Attachment<T> key) The value, or the attachment's default if none was set.booleanhas(Attachment<?> key) Whether a value is stored, rather than read from the default.static booleanhasSaved(net.minecraft.nbt.CompoundTag tag) Whether saved data holds any mod's attachments.booleanWhether the holder is on a client.booleanisValid()Whether the holder still exists: the entity or block entity isn't removed, the stack isn't empty.@Nullable net.minecraft.world.level.Levellevel()voidload(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) voidmarkDirty(Attachment<?> key) Saves and syncs a value that was changed in place, withoutAttachmentHolder.modify(net.ixdarklord.coolcatcore.api.attachment.Attachment<T>, java.util.function.Consumer<T>).<T> voidmodify(Attachment<T> key, Consumer<T> mutator) Changes a mutable value in place, then saves and syncs it.owner()The entity, block entity or item stack holding the values.voidreset(Attachment<?> key) Removes the value, so the default is read again.voidsave(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) <T> voidset(Attachment<T> key, T value) Sets the value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.ixdarklord.coolcatcore.api.attachment.AttachmentHolder
update
-
Constructor Details
-
AttachmentStore
-
-
Method Details
-
owner
Description copied from interface:AttachmentHolderThe entity, block entity or item stack holding the values.- Specified by:
ownerin interfaceAttachmentHolder
-
level
@Nullable public @Nullable net.minecraft.world.level.Level level() -
isClientSide
public boolean isClientSide()Description copied from interface:AttachmentHolderWhether the holder is on a client. Alwaysfalsefor item stacks, which have no side.- Specified by:
isClientSidein interfaceAttachmentHolder
-
isValid
public boolean isValid()Description copied from interface:AttachmentHolderWhether the holder still exists: the entity or block entity isn't removed, the stack isn't empty.- Specified by:
isValidin interfaceAttachmentHolder
-
get
Description copied from interface:AttachmentHolderThe value, or the attachment's default if none was set.- Specified by:
getin interfaceAttachmentHolder
-
set
Description copied from interface:AttachmentHolderSets the value. Setting an equal value does nothing.- Specified by:
setin interfaceAttachmentHolder
-
modify
Description copied from interface:AttachmentHolderChanges a mutable value in place, then saves and syncs it. Not for item stacks, whose values are immutable: useAttachmentHolder.update(net.ixdarklord.coolcatcore.api.attachment.Attachment<T>, java.util.function.UnaryOperator<T>)there.- Specified by:
modifyin interfaceAttachmentHolder
-
markDirty
Description copied from interface:AttachmentHolderSaves and syncs a value that was changed in place, withoutAttachmentHolder.modify(net.ixdarklord.coolcatcore.api.attachment.Attachment<T>, java.util.function.Consumer<T>).- Specified by:
markDirtyin interfaceAttachmentHolder
-
has
Description copied from interface:AttachmentHolderWhether a value is stored, rather than read from the default.- Specified by:
hasin interfaceAttachmentHolder
-
reset
Description copied from interface:AttachmentHolderRemoves the value, so the default is read again.- Specified by:
resetin interfaceAttachmentHolder
-
attachments
Description copied from interface:AttachmentHolderThe attachments with a stored value.- Specified by:
attachmentsin interfaceAttachmentHolder
-
save
public void save(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) -
hasSaved
public static boolean hasSaved(net.minecraft.nbt.CompoundTag tag) Whether saved data holds any mod's attachments. -
load
public void load(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider registries) -
copyFrom
public void copyFrom(AttachmentStore other, Predicate<Attachment<?>> filter, net.minecraft.core.HolderLookup.Provider registries) Copies another store's values, deep-copying persistent ones through their codec. Transient values are shared, except trackable ones, which can't have two owners.
-