Record Class ClickPayload

java.lang.Object
java.lang.Record
de.Keyle.MyPet.api.gui.ClickPayload
Record Components:
slot - the clicked slot
itemIndex - page-relative index within a paginated list, or -1 elsewhere
clickType - how the slot was clicked
shift - whether shift was held
cursor - what the player was holding on the cursor

public record ClickPayload(int slot, int itemIndex, ClickType clickType, boolean shift, ItemStack cursor) extends Record
Payload routed to MenuHandler.onClick(de.Keyle.MyPet.api.gui.MenuInstance, java.lang.String, de.Keyle.MyPet.api.gui.ClickPayload) for every click inside a tracked menu. `itemIndex` is the index inside a paginated-list section (or -1 for non-list sections).
  • Constructor Details

    • ClickPayload

      public ClickPayload(int slot, int itemIndex, ClickType clickType, boolean shift, ItemStack cursor)
      Creates an instance of a ClickPayload record class.
      Parameters:
      slot - the value for the slot record component
      itemIndex - the value for the itemIndex record component
      clickType - the value for the clickType record component
      shift - the value for the shift record component
      cursor - the value for the cursor record component
  • Method Details

    • forSlot

      public static ClickPayload forSlot(int slot, ClickType type, boolean shift, ItemStack cursor)
      Creates a payload for a click outside any paginated list, with no item index.
      Parameters:
      slot - the clicked slot
      type - how the slot was clicked
      shift - whether shift was held
      cursor - what the player was holding on the cursor
      Returns:
      a payload whose itemIndex is -1
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • slot

      public int slot()
      Returns the value of the slot record component.
      Returns:
      the value of the slot record component
    • itemIndex

      public int itemIndex()
      Returns the value of the itemIndex record component.
      Returns:
      the value of the itemIndex record component
    • clickType

      public ClickType clickType()
      Returns the value of the clickType record component.
      Returns:
      the value of the clickType record component
    • shift

      public boolean shift()
      Returns the value of the shift record component.
      Returns:
      the value of the shift record component
    • cursor

      public ItemStack cursor()
      Returns the value of the cursor record component.
      Returns:
      the value of the cursor record component