Record Class SlotHoverResult

java.lang.Object
java.lang.Record
com.trevlar.menukit.api.host.SlotHoverResult
Record Components:
handled - whether the hook took the point
slot - the winning slot, or null for PASS and BLOCK

public record SlotHoverResult(boolean handled, @Nullable net.minecraft.world.inventory.Slot slot) extends Record
What SlotScreenHook.resolveHover(AbstractContainerScreen, double, double) answers for a screen point. It carries only vanilla's Slot.
  • PASS: no shown slot takes the point; vanilla's slot resolution runs untouched.
  • of(Slot): a shown slot is under the point and replaces vanilla's answer. It must be the slot in the screen's own menu.slots (on the creative screen, the wrapper around it, since creative's click path casts the hovered slot to its wrapper).
  • BLOCK: the point is inside a shown slot panel but between slots; the covered vanilla slot is inert, so a click in the gap cannot fall through.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final SlotHoverResult
    Inside a shown slot panel but on a gap: blocked, the covered slot is inert.
    static final SlotHoverResult
    No slot takes the point, so vanilla's resolution runs.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SlotHoverResult(boolean handled, @Nullable net.minecraft.world.inventory.Slot slot)
    Creates an instance of a SlotHoverResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the handled record component.
    final int
    Returns a hash code value for this object.
    of(net.minecraft.world.inventory.Slot slot)
    A shown slot wins the point.
    @Nullable net.minecraft.world.inventory.Slot
    Returns the value of the slot 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
  • Field Details

    • PASS

      public static final SlotHoverResult PASS
      No slot takes the point, so vanilla's resolution runs.
    • BLOCK

      public static final SlotHoverResult BLOCK
      Inside a shown slot panel but on a gap: blocked, the covered slot is inert.
  • Constructor Details

    • SlotHoverResult

      public SlotHoverResult(boolean handled, @Nullable net.minecraft.world.inventory.Slot slot)
      Creates an instance of a SlotHoverResult record class.
      Parameters:
      handled - the value for the handled record component
      slot - the value for the slot record component
  • Method Details

    • of

      public static SlotHoverResult of(net.minecraft.world.inventory.Slot slot)
      A shown slot wins the point. Pass the slot that is in menu.slots.
    • 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 the compare method from their corresponding wrapper classes.
      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.
    • handled

      public boolean handled()
      Returns the value of the handled record component.
      Returns:
      the value of the handled record component
    • slot

      public @Nullable net.minecraft.world.inventory.Slot slot()
      Returns the value of the slot record component.
      Returns:
      the value of the slot record component