java.lang.Object
io.github.toberocat.guiengine.utils.Utils

public final class Utils extends Object
Utility class containing various helper methods for GUI development.
  • 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

      @NotNull public static @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.
      Parameters:
      slot - The slot index in the inventory.
      Returns:
      A CoordinatePair representing the x and y coordinates in the grid.