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 Detail

      • 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,
                                             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:
        Inventory.poll()
      • 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:
        Inventory.peek()
      • 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