Record Class SlotRef

java.lang.Object
java.lang.Record
com.trevlar.slotkit.api.window.SlotRef
Record Components:
container - the container the slot reads and writes
containerSlot - the slot's index within container
slot - the live slot on the menu, or null off-menu
menu - the open menu, or null off-menu
player - who is acting, or null for automation
category - the slot's category on menu, or null when off-menu or in no category
address - the slot's window address, or null when the seam cannot identify the container

public record SlotRef(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.inventory.AbstractContainerMenu menu, @Nullable net.minecraft.world.entity.player.Player player, @Nullable SlotGroupCategory category, @Nullable Address address) extends Record
The slot an operation is about to act on, as much of it as the seam can supply. What a SlotOperations.Veto sees.

Every seam has the backing Container and the container-relative index, which is how a locking mod already keys its locks (the player inventory by index, an ender chest by index, a placed container by identity). A menu seam also has the live Slot and its menu, and from those the slot's SlotGroupCategory on that menu. A click seam has the acting Player; a per-player lock needs to know whose click this is, so a LAN guest is not checked against the host's locks. The slot's Address is here too, minted once by the installed rule, so a veto that keys on it never derives it itself. Anything the seam does not have is null: an inventory insert (Inventory.getFreeSlot) has no menu and no slot, only the inventory, its index and its owner, and an address only where the container has an identity.

  • Constructor Summary

    Constructors
    Constructor
    Description
    SlotRef(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.inventory.AbstractContainerMenu menu, @Nullable net.minecraft.world.entity.player.Player player, @Nullable SlotGroupCategory category, @Nullable Address address)
    Creates an instance of a SlotRef record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Address
    Returns the value of the address record component.
    static Address
    addressOf(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot)
     
    Returns the value of the category record component.
    net.minecraft.world.Container
    Returns the value of the container record component.
    int
    Returns the value of the containerSlot record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static SlotRef
    inventory(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.entity.player.Player player, int index)
    The player-inventory slot at index as it sits on menu, so it resolves with its menu category; the bare container form when the menu does not show it (vanilla swaps against the inventory directly, so the swap works on such a menu too).
    @Nullable net.minecraft.world.inventory.AbstractContainerMenu
    Returns the value of the menu record component.
    static SlotRef
    of(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.entity.player.Player player)
    A slot reached with no menu open: an inventory insert.
    static SlotRef
    of(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.entity.player.Player player)
    A slot reached through an open menu: the click and shift-click seams.
    @Nullable net.minecraft.world.entity.player.Player
    Returns the value of the player record component.
    @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
  • Constructor Details

    • SlotRef

      public SlotRef(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.inventory.AbstractContainerMenu menu, @Nullable net.minecraft.world.entity.player.Player player, @Nullable SlotGroupCategory category, @Nullable Address address)
      Creates an instance of a SlotRef record class.
      Parameters:
      container - the value for the container record component
      containerSlot - the value for the containerSlot record component
      slot - the value for the slot record component
      menu - the value for the menu record component
      player - the value for the player record component
      category - the value for the category record component
      address - the value for the address record component
  • Method Details

    • of

      public static SlotRef of(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot, @Nullable net.minecraft.world.entity.player.Player player)
      A slot reached through an open menu: the click and shift-click seams.
    • inventory

      public static SlotRef inventory(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.entity.player.Player player, int index)
      The player-inventory slot at index as it sits on menu, so it resolves with its menu category; the bare container form when the menu does not show it (vanilla swaps against the inventory directly, so the swap works on such a menu too).
    • of

      public static SlotRef of(net.minecraft.world.Container container, int containerSlot, @Nullable net.minecraft.world.entity.player.Player player)
      A slot reached with no menu open: an inventory insert.
    • addressOf

      @Internal public static Address addressOf(net.minecraft.world.inventory.AbstractContainerMenu menu, net.minecraft.world.inventory.Slot slot)
    • 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.
    • container

      public net.minecraft.world.Container container()
      Returns the value of the container record component.
      Returns:
      the value of the container record component
    • containerSlot

      public int containerSlot()
      Returns the value of the containerSlot record component.
      Returns:
      the value of the containerSlot 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
    • player

      public @Nullable net.minecraft.world.entity.player.Player player()
      Returns the value of the player record component.
      Returns:
      the value of the player record component
    • category

      public @Nullable SlotGroupCategory category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • address

      public @Nullable Address address()
      Returns the value of the address record component.
      Returns:
      the value of the address record component