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

    Constructors
    Constructor
    Description
    ItemStackAttachments(net.minecraft.world.item.ItemStack stack)
    Creates an instance of a ItemStackAttachments record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    The attachments with a stored value.
    final boolean
    Indicates whether some other object is "equal to" this one.
    <T> T
    get(Attachment<T> attachment)
    The value, or the attachment's default if none was set.
    boolean
    has(Attachment<?> attachment)
    Whether a value is stored, rather than read from the default.
    final int
    Returns a hash code value for this object.
    boolean
    Whether the holder is on a client.
    boolean
    Whether the holder still exists: the entity or block entity isn't removed, the stack isn't empty.
    void
    markDirty(Attachment<?> attachment)
    Saves and syncs a value that was changed in place, without AttachmentHolder.modify(Attachment, Consumer).
    <T> void
    modify(Attachment<T> attachment, Consumer<T> mutator)
    Changes a mutable value in place, then saves and syncs it.
    The entity, block entity or item stack holding the values.
    void
    reset(Attachment<?> attachment)
    Removes the value, so the default is read again.
    <T> void
    set(Attachment<T> attachment, T value)
    Sets the value.
    net.minecraft.world.item.ItemStack
    Returns the value of the stack record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface AttachmentHolder

    update
  • Constructor Details

    • ItemStackAttachments

      public ItemStackAttachments(net.minecraft.world.item.ItemStack stack)
      Creates an instance of a ItemStackAttachments record class.
      Parameters:
      stack - the value for the stack record component
  • Method Details

    • owner

      public Object owner()
      Description copied from interface: AttachmentHolder
      The entity, block entity or item stack holding the values.
      Specified by:
      owner in interface AttachmentHolder
    • isClientSide

      public boolean isClientSide()
      Description copied from interface: AttachmentHolder
      Whether the holder is on a client. Always false for item stacks, which have no side.
      Specified by:
      isClientSide in interface AttachmentHolder
    • isValid

      public boolean isValid()
      Description copied from interface: AttachmentHolder
      Whether the holder still exists: the entity or block entity isn't removed, the stack isn't empty.
      Specified by:
      isValid in interface AttachmentHolder
    • get

      public <T> T get(Attachment<T> attachment)
      Description copied from interface: AttachmentHolder
      The value, or the attachment's default if none was set.
      Specified by:
      get in interface AttachmentHolder
    • set

      public <T> void set(Attachment<T> attachment, T value)
      Description copied from interface: AttachmentHolder
      Sets the value. Setting an equal value does nothing.
      Specified by:
      set in interface AttachmentHolder
    • modify

      public <T> void modify(Attachment<T> attachment, Consumer<T> mutator)
      Description copied from interface: AttachmentHolder
      Changes a mutable value in place, then saves and syncs it. Not for item stacks, whose values are immutable: use AttachmentHolder.update(Attachment, UnaryOperator) there.
      Specified by:
      modify in interface AttachmentHolder
    • markDirty

      public void markDirty(Attachment<?> attachment)
      Description copied from interface: AttachmentHolder
      Saves and syncs a value that was changed in place, without AttachmentHolder.modify(Attachment, Consumer).
      Specified by:
      markDirty in interface AttachmentHolder
    • has

      public boolean has(Attachment<?> attachment)
      Description copied from interface: AttachmentHolder
      Whether a value is stored, rather than read from the default.
      Specified by:
      has in interface AttachmentHolder
    • reset

      public void reset(Attachment<?> attachment)
      Description copied from interface: AttachmentHolder
      Removes the value, so the default is read again.
      Specified by:
      reset in interface AttachmentHolder
    • attachments

      public Set<Attachment<?>> attachments()
      Description copied from interface: AttachmentHolder
      The attachments with a stored value.
      Specified by:
      attachments in interface AttachmentHolder
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • stack

      public net.minecraft.world.item.ItemStack stack()
      Returns the value of the stack record component.
      Returns:
      the value of the stack record component