Class SlotUtil
java.lang.Object
com.github.darksoulq.abyssallib.world.gui.SlotUtil
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 Summary
Modifier and TypeMethodDescriptionstatic 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.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.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.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.static List<SlotPosition> row(GuiView.Segment segment, int startSlot, int length, int maxCols) Generates a list of positions forming a horizontal row.
-
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 fromrows- the height of the rectangle in rowscols- the width of the rectangle in columnsmaxRows- the maximum number of rows in the inventorymaxCols- 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 beginslength- the number of slots in the rowmaxCols- 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 beginsstep- the vertical increment between slots (usually 1)length- the number of slots in the columnmaxRows- the maximum number of rows in the inventorymaxCols- 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 gridrows- the number of rows in the gridcols- the number of columns in the gridmaxRows- the maximum number of rows in the inventorymaxCols- 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 offsetsmaxRows- the maximum number of rows in the inventorymaxCols- the maximum number of columns in the inventoryoffsets- the integer offsets relative to the startSlot index- Returns:
- a list of validated slot positions
-