Class SlotGetter
java.lang.Object
net.xun.lib.common.api.inventory.slot.SlotGetter
Utility class for calculating inventory slot indices based on grid coordinates (rows/columns),
inventory sections, and container-to-inventory conversions.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intgetContainerSlot(int row, int column, int slotsPerRow) Converts GUI grid coordinates (row and column) to the corresponding container slot index.static intgetHotbarSlotIndex(int number) Returns the hotbar slot index corresponding to the given hotbar number.static intgetInventorySlotIndex(int row, int column, PlayerInventorySection section) Converts grid coordinates (row and column) within a specific inventory section to the corresponding inventory slot index.
-
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 0column- the column in the GUI, starting from 0slotsPerRow- 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
Converts grid coordinates (row and column) within a specific inventory section to the corresponding inventory slot index.- Parameters:
row- the row within the inventory sectioncolumn- the column within the inventory sectionsection- 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
-