Record Class ItemStackAttachments
java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcore.internal.attachment.ItemStackAttachments
- All Implemented Interfaces:
AttachmentHolder
public record ItemStackAttachments(net.minecraft.world.item.ItemStack stack)
extends Record
implements AttachmentHolder
-
Constructor Summary
ConstructorsConstructorDescriptionItemStackAttachments(net.minecraft.world.item.ItemStack stack) Creates an instance of aItemStackAttachmentsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionSet<Attachment<?>> The attachments with a stored value.final booleanIndicates whether some other object is "equal to" this one.<T> Tget(Attachment<T> attachment) The value, or the attachment's default if none was set.booleanhas(Attachment<?> attachment) Whether a value is stored, rather than read from the default.final inthashCode()Returns a hash code value for this object.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.voidmarkDirty(Attachment<?> attachment) 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> attachment, 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<?> attachment) Removes the value, so the default is read again.<T> voidset(Attachment<T> attachment, T value) Sets the value.net.minecraft.world.item.ItemStackstack()Returns the value of thestackrecord component.final StringtoString()Returns a string representation of this record class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.ixdarklord.coolcatcore.api.attachment.AttachmentHolder
update
-
Constructor Details
-
ItemStackAttachments
public ItemStackAttachments(net.minecraft.world.item.ItemStack stack) Creates an instance of aItemStackAttachmentsrecord class.- Parameters:
stack- the value for thestackrecord component
-
-
Method Details
-
owner
Description copied from interface:AttachmentHolderThe entity, block entity or item stack holding the values.- Specified by:
ownerin interfaceAttachmentHolder
-
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
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
stack
public net.minecraft.world.item.ItemStack stack()Returns the value of thestackrecord component.- Returns:
- the value of the
stackrecord component
-