Interface GridInventory
- All Superinterfaces:
Inventory
,Inventory2D
,ValueContainer
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.item.inventory.Inventory
Inventory.Builder
-
Method Summary
Modifier and TypeMethodDescriptioncolumn
(int x) Gets the column at the specified index.int
columns()
Gets the number of columns in the inventory.Returns the dimensions of this GridInventory as aVector2i
.peek
(int x, int y) Gets without removing the stack at the supplied position in this Inventory.poll
(int x, int y) Gets and remove the stack at the supplied position in this Inventory.poll
(int x, int y, int limit) Gets and remove the stack at the supplied position in this Inventory.row
(int y) Gets the row at the specified index.int
rows()
Gets the number of rows in the inventory.Sets the item in the specified 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 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 aVector2i
.- Returns:
- The dimensions of this GridInventory.
-
poll
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:
-
poll
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:
-
peek
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:
-
set
Sets the item in the specified slot.- Parameters:
x
- x coordinatey
- y coordinatestack
- Item stack to insert- Returns:
- operation result
- See Also:
-
slot
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
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
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
-