Interface GridInventory

All Superinterfaces:
Inventory, Inventory2D, ValueContainer

public interface GridInventory extends Inventory2D
An GridInventory is an Inventory which is ordered into a coherent grid format, meaning that its slots can be referred to by X-Y coordinates as well as single indices.
  • Method Details

    • columns

      int columns()
      Gets the number of columns in the inventory.
      Returns:
      The width of this ItemGrid.
    • rows

      int rows()
      Gets the number of rows in the inventory.
      Returns:
      The height of this ItemGrid.
    • dimensions

      Vector2i dimensions()
      Returns the dimensions of this GridInventory as a Vector2i.
      Returns:
      The dimensions of this GridInventory.
    • poll

      InventoryTransactionResult.Poll poll(int x, int y)
      Gets and remove the stack at the supplied position in this Inventory.
      Parameters:
      x - x coordinate
      y - y coordinate
      Returns:
      ItemStack at the specified position or Optional.empty() if the slot is empty or out of bounds
      See Also:
    • poll

      InventoryTransactionResult.Poll poll(int x, int y, int limit)
      Gets and remove the stack at the supplied position in this Inventory.
      Parameters:
      x - x coordinate
      y - y coordinate
      limit - item limit
      Returns:
      ItemStack at the specified position or Optional.empty() if the slot is empty or out of bounds
      See Also:
    • peek

      Optional<ItemStack> peek(int x, int y)
      Gets without removing the stack at the supplied position in this Inventory.
      Parameters:
      x - x coordinate
      y - y coordinate
      Returns:
      ItemStack at the specified position or Optional.empty() if the slot is empty or out of bounds
      See Also:
    • set

      InventoryTransactionResult set(int x, int y, ItemStack stack)
      Sets the item in the specified slot.
      Parameters:
      x - x coordinate
      y - y coordinate
      stack - Item stack to insert
      Returns:
      operation result
      See Also:
    • slot

      Optional<Slot> slot(int x, int y)
      Gets the Slot at the specified position.
      Parameters:
      x - x coordinate
      y - y coordinate
      Returns:
      Slot at the specified position or Optional.empty() if the coordinates are out of bounds
    • row

      Optional<InventoryRow> row(int y)
      Gets the row at the specified index.
      Parameters:
      y - y coordinate
      Returns:
      InventoryRow at the specified position or Optional.empty() if the specified row is out of bounds
    • column

      Optional<InventoryColumn> column(int x)
      Gets the column at the specified index.
      Parameters:
      x - x coordinate
      Returns:
      InventoryColumn at the specified position or Optional.empty() if the specified column is out of bounds