Interface CraftingInput


@NonExtendable public interface CraftingInput
The contents of a crafting grid, row by row from the top-left corner.

The grid of the player inventory is 2×2, the one of a crafting table 3×3. Empty slots hold ItemStack.EMPTY. Instances are immutable snapshots.

Since:
0.1.0
  • Method Details

    • of

      static CraftingInput of(int width, int height, List<ItemStack> items)
      Parameters:
      width - the number of columns
      height - the number of rows
      items - width * height stacks, row-major
      Returns:
      a snapshot of that grid, to match or test against
      Throws:
      IllegalArgumentException - if the grid is smaller than 1×1 or items has the wrong size
      Since:
      0.1.0
    • width

      int width()
      Returns:
      the number of columns
      Since:
      0.1.0
    • height

      int height()
      Returns:
      the number of rows
      Since:
      0.1.0
    • items

      List<ItemStack> items()
      Returns:
      width * height stacks, row-major
      Since:
      0.1.0
    • get

      ItemStack get(int slot)
      Parameters:
      slot - the slot index, row-major
      Returns:
      the stack in that slot, ItemStack.EMPTY when it is empty
      Since:
      0.1.0
    • get

      ItemStack get(int x, int y)
      Parameters:
      x - the column, from 0 on the left
      y - the row, from 0 at the top
      Returns:
      the stack at that position, ItemStack.EMPTY when it is empty
      Since:
      0.1.0
    • size

      int size()
      Returns:
      width * height
      Since:
      0.1.0
    • nonEmptyCount

      int nonEmptyCount()
      Returns:
      how many slots hold something
      Since:
      0.1.0
    • isEmpty

      boolean isEmpty()
      Returns:
      true when every slot is empty
      Since:
      0.1.0