Class Utils
java.lang.Object
io.github.toberocat.guiengine.utils.Utils
Utility class containing various helper methods for GUI development.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull CoordinatePair
translateFromSlot
(int slot) Translates a slot index in a 1D inventory slot array (9 slots per row) to x and y coordinates of a 2D grid.static int
translateToSlot
(int x, int y) Translates the x and y coordinates of a 2D grid to a slot index in a 1D inventory slot array (9 slots per row).
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
translateToSlot
public static int translateToSlot(int x, int y) Translates the x and y coordinates of a 2D grid to a slot index in a 1D inventory slot array (9 slots per row).- Parameters:
x
- The x-coordinate (column index) of the grid.y
- The y-coordinate (row index) of the grid.- Returns:
- The corresponding slot index in the inventory.
-
translateFromSlot
Translates a slot index in a 1D inventory slot array (9 slots per row) to x and y coordinates of a 2D grid.- Parameters:
slot
- The slot index in the inventory.- Returns:
- A CoordinatePair representing the x and y coordinates in the grid.
-