PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
Loading...
Searching...
No Matches
pocketmine\inventory\Inventory Interface Reference
+ Inheritance diagram for pocketmine\inventory\Inventory:
+ Collaboration diagram for pocketmine\inventory\Inventory:

Public Member Functions

 addItem (Item ... $slots)
 
 all (Item $item)
 
 canAddItem (Item $item)
 
 clear (int $index)
 
 clearAll ()
 
 contains (Item $item)
 
 first (Item $item, bool $exact=false)
 
 firstEmpty ()
 
 getAddableItemQuantity (Item $item)
 
 getContents (bool $includeEmpty=false)
 
 getItem (int $index)
 
 getListeners ()
 
 getMaxStackSize ()
 
 getSize ()
 
 getViewers ()
 
 isSlotEmpty (int $index)
 
 onClose (Player $who)
 
 onOpen (Player $who)
 
 remove (Item $item)
 
 removeItem (Item ... $slots)
 
 setContents (array $items)
 
 setItem (int $index, Item $item)
 
 setMaxStackSize (int $size)
 
 slotExists (int $slot)
 
 swap (int $slot1, int $slot2)
 

Public Attributes

const MAX_STACK = 64
 

Detailed Description

Definition at line 33 of file Inventory.php.

Member Function Documentation

◆ addItem()

pocketmine\inventory\Inventory::addItem ( Item ... $slots)

Stores the given Items in the inventory. This will add to any non-full existing stacks first, and then put the remaining items in empty slots if there are any available.

Returns an array of items which could not fit in the inventory.

Returns
Item[]

Implemented in pocketmine\inventory\BaseInventory.

◆ all()

pocketmine\inventory\Inventory::all ( Item $item)

Returns all matching items in the inventory, irrespective of stack size. The returned array is indexed by slot number.

If the input item has specific NBT, only items with the same type and NBT will match. Otherwise, only the item type is checked.

Returns
Item[] @phpstan-return array<int, Item>

Implemented in pocketmine\inventory\BaseInventory.

◆ canAddItem()

pocketmine\inventory\Inventory::canAddItem ( Item $item)

Checks if a given Item can be added to the inventory

Implemented in pocketmine\block\inventory\ShulkerBoxInventory, and pocketmine\inventory\BaseInventory.

◆ clear()

pocketmine\inventory\Inventory::clear ( int $index)

Will clear a specific slot

Implemented in pocketmine\inventory\BaseInventory.

◆ clearAll()

pocketmine\inventory\Inventory::clearAll ( )

Clears all the slots

Implemented in pocketmine\inventory\BaseInventory.

◆ contains()

pocketmine\inventory\Inventory::contains ( Item $item)

Returns whether the total amount of matching items is at least the stack size of the given item. Multiple stacks of the same item are added together.

If the input item has specific NBT, only items with the same type and NBT will match. Otherwise, only the item type is checked.

Implemented in pocketmine\inventory\BaseInventory.

◆ first()

pocketmine\inventory\Inventory::first ( Item $item,
bool $exact = false )

Returns the first slot number containing a matching item with a stack size greater than or equal to the input item.

If the input item has specific NBT, or if $exact is true, only items with the same type and NBT will match. Otherwise, only the item type is checked.

Implemented in pocketmine\inventory\BaseInventory.

◆ firstEmpty()

pocketmine\inventory\Inventory::firstEmpty ( )

Returns the first empty slot, or -1 if not found

Implemented in pocketmine\inventory\BaseInventory.

◆ getAddableItemQuantity()

pocketmine\inventory\Inventory::getAddableItemQuantity ( Item $item)

Returns how many items from the given itemstack can be added to this inventory.

Implemented in pocketmine\inventory\BaseInventory.

◆ getContents()

pocketmine\inventory\Inventory::getContents ( bool $includeEmpty = false)

Returns an array of all the itemstacks in the inventory, indexed by their slot number. Empty slots are not included unless includeEmpty is true.

Returns
Item[] @phpstan-return array<int, Item>

Implemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, pocketmine\inventory\SimpleInventory, and pocketmine\inventory\transaction\TransactionBuilderInventory.

◆ getItem()

pocketmine\inventory\Inventory::getItem ( int $index)

◆ getListeners()

pocketmine\inventory\Inventory::getListeners ( )
Returns
InventoryListener[]|ObjectSet @phpstan-return ObjectSet<InventoryListener>

Implemented in pocketmine\inventory\BaseInventory.

◆ getMaxStackSize()

pocketmine\inventory\Inventory::getMaxStackSize ( )

Returns the maximum stack size for items in this inventory. Individual item types (such as armor or tools) may have a smaller maximum stack size.

Implemented in pocketmine\block\inventory\CampfireInventory, and pocketmine\inventory\BaseInventory.

◆ getSize()

◆ getViewers()

pocketmine\inventory\Inventory::getViewers ( )

Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.

Returns
Player[]

Implemented in pocketmine\inventory\BaseInventory.

◆ isSlotEmpty()

pocketmine\inventory\Inventory::isSlotEmpty ( int $index)

◆ onOpen()

pocketmine\inventory\Inventory::onOpen ( Player $who)

Called when a player opens this inventory.

Implemented in pocketmine\inventory\BaseInventory.

◆ remove()

pocketmine\inventory\Inventory::remove ( Item $item)

Clears all slots containing items equivalent to the given item.

If the input item has specific NBT, only items with the same type and NBT will match. Otherwise, only the item type is checked.

Implemented in pocketmine\inventory\BaseInventory.

◆ removeItem()

pocketmine\inventory\Inventory::removeItem ( Item ... $slots)

Removes items from the inventory in the amounts specified by the given itemstacks. Returns an array of items that couldn't be removed.

If the input item has specific NBT, only items with the same type and NBT will match. Otherwise, only the item type is checked.

Returns
Item[]

Implemented in pocketmine\inventory\BaseInventory.

◆ setContents()

pocketmine\inventory\Inventory::setContents ( array $items)

Sets the contents of the inventory. Non-numeric offsets or offsets larger than the size of the inventory are ignored.

Parameters
Item[]$items@phpstan-param array<int, Item> $items

Implemented in pocketmine\inventory\BaseInventory.

◆ setItem()

pocketmine\inventory\Inventory::setItem ( int $index,
Item $item )

Puts an Item in a slot.

Implemented in pocketmine\crafting\CraftingGrid, and pocketmine\inventory\BaseInventory.

◆ setMaxStackSize()

pocketmine\inventory\Inventory::setMaxStackSize ( int $size)

Sets the maximum stack size for items in this inventory.

Implemented in pocketmine\inventory\BaseInventory.

◆ slotExists()

pocketmine\inventory\Inventory::slotExists ( int $slot)

Returns whether the specified slot exists in the inventory.

Implemented in pocketmine\inventory\BaseInventory.

Referenced by pocketmine\network\mcpe\InventoryManager\locateWindowAndSlot().

+ Here is the caller graph for this function:

◆ swap()

pocketmine\inventory\Inventory::swap ( int $slot1,
int $slot2 )

Swaps the specified slots.

Implemented in pocketmine\inventory\BaseInventory.

Member Data Documentation

◆ MAX_STACK

const pocketmine\inventory\Inventory::MAX_STACK = 64

Definition at line 34 of file Inventory.php.


The documentation for this interface was generated from the following file: