Class SlotUtil

java.lang.Object
com.github.darksoulq.abyssallib.world.gui.SlotUtil

public final class SlotUtil extends Object
A utility class for calculating inventory slot positions.

This class provides helper methods to generate collections of SlotPosition based on geometric patterns such as rows, columns, grids, and borders.

  • Method Details

    • border

      public static List<SlotPosition> border(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols)
      Generates a list of positions forming the border of a rectangular area.
      Parameters:
      segment - the inventory segment (TOP or BOTTOM)
      startSlot - the top-left slot index to start from
      rows - the height of the rectangle in rows
      cols - the width of the rectangle in columns
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      Returns:
      a list of slot positions forming the outline
    • row

      public static List<SlotPosition> row(GuiView.Segment segment, int startSlot, int length, int maxCols)
      Generates a list of positions forming a horizontal row.
      Parameters:
      segment - the inventory segment (TOP or BOTTOM)
      startSlot - the slot index where the row begins
      length - the number of slots in the row
      maxCols - the maximum number of columns in the inventory
      Returns:
      a list of slot positions in the row
    • column

      public static List<SlotPosition> column(GuiView.Segment segment, int startSlot, int step, int length, int maxRows, int maxCols)
      Generates a list of positions forming a vertical column.
      Parameters:
      segment - the inventory segment (TOP or BOTTOM)
      startSlot - the slot index where the column begins
      step - the vertical increment between slots (usually 1)
      length - the number of slots in the column
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      Returns:
      a list of slot positions in the column
    • grid

      public static List<SlotPosition> grid(GuiView.Segment segment, int startSlot, int rows, int cols, int maxRows, int maxCols)
      Generates a list of positions forming a solid rectangular grid.
      Parameters:
      segment - the inventory segment (TOP or BOTTOM)
      startSlot - the top-left slot index of the grid
      rows - the number of rows in the grid
      cols - the number of columns in the grid
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      Returns:
      a list of all slot positions within the grid
    • pattern

      public static List<SlotPosition> pattern(GuiView.Segment segment, int startSlot, int maxRows, int maxCols, int... offsets)
      Generates a list of positions based on a relative integer offset pattern.
      Parameters:
      segment - the inventory segment (TOP or BOTTOM)
      startSlot - the reference slot index for the offsets
      maxRows - the maximum number of rows in the inventory
      maxCols - the maximum number of columns in the inventory
      offsets - the integer offsets relative to the startSlot index
      Returns:
      a list of validated slot positions