Class SlotGetter

java.lang.Object
net.xun.lib.common.api.inventory.slot.SlotGetter

public class SlotGetter extends Object
Utility class for calculating inventory slot indices based on grid coordinates (rows/columns), inventory sections, and container-to-inventory conversions.
  • Constructor Details

    • SlotGetter

      public SlotGetter()
  • Method Details

    • getContainerSlot

      public static int getContainerSlot(int row, int column, int slotsPerRow)
      Converts GUI grid coordinates (row and column) to the corresponding container slot index.
      Parameters:
      row - the row in the GUI, starting from 0
      column - the column in the GUI, starting from 0
      slotsPerRow - the number of slots per row in the container's GUI
      Returns:
      the calculated slot index
      Throws:
      IllegalArgumentException - if guiColumn is out of bounds for the given slotsPerRow
    • getInventorySlotIndex

      public static int getInventorySlotIndex(int row, int column, PlayerInventorySection section)
      Converts grid coordinates (row and column) within a specific inventory section to the corresponding inventory slot index.
      Parameters:
      row - the row within the inventory section
      column - the column within the inventory section
      section - the inventory section (HOTBAR, ARMOR, MAIN_INVENTORY)
      Returns:
      the calculated inventory slot index
      Throws:
      IllegalArgumentException - if the row or column is invalid for the given section
    • getHotbarSlotIndex

      public static int getHotbarSlotIndex(int number)
      Returns the hotbar slot index corresponding to the given hotbar number.
      Parameters:
      number - the hotbar number (0-8)
      Returns:
      the hotbar slot index
      Throws:
      IllegalArgumentException - if the number is outside the valid range