Interface Container
-
- All Superinterfaces:
Inventory
,ValueContainer
public interface Container extends Inventory
A Container is effectively a ViewModel for a particular set ofInventory
objects used to allow players to interact with the Inventories, usually via a GUI (the View).
-
-
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<ItemStack>
cursor()
Gets the viewing players cursor item.boolean
isOpen()
Returns whether this Container is open.boolean
isViewedSlot(Slot slot)
Returns whether given slot is part of the viewed inventories but not part of the viewers own inventory.boolean
setCursor(ItemStack item)
Sets the viewing players cursor item.ContainerType
type()
Returns theContainerType
of this container.List<Inventory>
viewed()
Returns the list of viewed inventories.ServerPlayer
viewer()
Gets the viewingplayer
.-
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
-
isViewedSlot
boolean isViewedSlot(Slot slot)
Returns whether given slot is part of the viewed inventories but not part of the viewers own inventory.Examples for viewed inventory slots:
All the slots of the opened chest and not the player grid below.
The slots of the crafting grid in the opened player inventory.
- Parameters:
slot
- The slot to check.- Returns:
true
when the slot is part of the viewed inventories.
-
viewed
List<Inventory> viewed()
Returns the list of viewed inventories.This is usually at least the inventory a player opened and the players inventory.
It is not necessary, that all slots of the viewed inventories are visible or interactable with.
- Returns:
- the list of viewed inventories.
-
setCursor
boolean setCursor(ItemStack item)
Sets the viewing players cursor item.Returns false when the container is no longer open.
- Parameters:
item
- The item to set.- Returns:
- true if the cursor was set.
-
cursor
Optional<ItemStack> cursor()
Gets the viewing players cursor item.Returns
Optional.empty()
when the container was closed.- Returns:
- The players cursor item.
-
viewer
ServerPlayer viewer()
Gets the viewingplayer
.- Returns:
- The viewing player
-
isOpen
boolean isOpen()
Returns whether this Container is open.- Returns:
- Whether this Container is open.
-
type
ContainerType type()
Returns theContainerType
of this container.- Returns:
- the ContainerType of this container.
-
-