Interface GridInventory
-
- All Superinterfaces:
Inventory
,Inventory2D
,ValueContainer
public interface GridInventory extends Inventory2D
An GridInventory is anInventory
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.spongepowered.api.item.inventory.Inventory
Inventory.Builder
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<InventoryColumn>
column(int x)
Gets the column at the specified index.int
columns()
Gets the number of columns in the inventory.Vector2i
dimensions()
Returns the dimensions of this GridInventory as aVector2i
.Optional<ItemStack>
peek(int x, int y)
Gets without removing the stack at the supplied position in this Inventory.InventoryTransactionResult.Poll
poll(int x, int y)
Gets and remove the stack at the supplied position in this Inventory.InventoryTransactionResult.Poll
poll(int x, int y, int limit)
Gets and remove the stack at the supplied position in this Inventory.Optional<InventoryRow>
row(int y)
Gets the row at the specified index.int
rows()
Gets the number of rows in the inventory.InventoryTransactionResult
set(int x, int y, ItemStack stack)
Sets the item in the specified slot.Optional<Slot>
slot(int x, int y)
Gets theSlot
at the specified position.-
Methods inherited from interface org.spongepowered.api.item.inventory.Inventory
asViewable, canFit, capacity, children, clear, contains, contains, containsAny, containsChild, containsInventory, freeCapacity, get, get, hasChildren, intersect, offer, offer, parent, peek, peekAt, poll, poll, pollFrom, pollFrom, query, query, query, query, query, query, root, set, slot, slots, totalQuantity, union
-
-
-
-
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 aVector2i
.- 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 coordinatey
- y coordinate- Returns:
- ItemStack at the specified position or
Optional.empty()
if the slot is empty or out of bounds - See Also:
Inventory.poll()
-
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 coordinatey
- y coordinatelimit
- 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 coordinatey
- y coordinate- Returns:
- ItemStack at the specified position or
Optional.empty()
if the slot is empty or out of bounds - See Also:
Inventory.peek()
-
set
InventoryTransactionResult set(int x, int y, ItemStack stack)
Sets the item in the specified slot.- Parameters:
x
- x coordinatey
- y coordinatestack
- Item stack to insert- Returns:
- operation result
- See Also:
Slot.set(ItemStack)
-
slot
Optional<Slot> slot(int x, int y)
Gets theSlot
at the specified position.- Parameters:
x
- x coordinatey
- y coordinate- Returns:
Slot
at the specified position orOptional.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 orOptional.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 orOptional.empty()
if the specified column is out of bounds
-
-