BaseInventory
Implements Inventory, SlotValidatedInventory
This class provides everything needed to implement an inventory, minus the underlying storage system.
Properties
$listeners protected
php
protected \pocketmine\utils\ObjectSet $listeners$maxStackSize protected
php
protected int $maxStackSize$validators protected
php
protected \pocketmine\utils\ObjectSet $validators$viewers protected
php
protected array $viewersMethods
__construct()
php
public function __construct()addItem()
php
public function addItem(\pocketmine\item\Item ...$slots) : arrayall()
php
public function all(\pocketmine\item\Item $item) : arraycanAddItem()
php
public function canAddItem(\pocketmine\item\Item $item) : boolclear()
php
public function clear(int $index) : voidclearAll()
php
public function clearAll() : voidcontains()
php
public function contains(\pocketmine\item\Item $item) : boolfirst()
php
public function first(\pocketmine\item\Item $item, bool $exact = false) : intfirstEmpty()
php
public function firstEmpty() : intgetAddableItemQuantity()
php
public function getAddableItemQuantity(\pocketmine\item\Item $item) : intgetListeners()
php
public function getListeners() : \pocketmine\utils\ObjectSetgetMatchingItemCount() protected
php
protected function getMatchingItemCount(int $slot, \pocketmine\item\Item $test, bool $checkTags) : intHelper for utility functions which search the inventory. TODO: make this abstract instead of providing a slow default implementation (BC break)
getMaxStackSize()
php
public function getMaxStackSize() : intgetSlotValidators()
php
public function getSlotValidators() : \pocketmine\utils\ObjectSetgetViewers()
php
public function getViewers() : arrayinternalSetContents() protected
php
abstract protected function internalSetContents(array $items) : voidinternalSetItem() protected
php
abstract protected function internalSetItem(int $index, \pocketmine\item\Item $item) : voidisSlotEmpty()
php
public function isSlotEmpty(int $index) : boolTODO: make this abstract and force implementations to implement it properly (BC break) This default implementation works, but is slow.
onClose()
php
public function onClose(\pocketmine\player\Player $who) : voidonContentChange() protected
php
protected function onContentChange(array $itemsBefore) : voidonOpen()
php
public function onOpen(\pocketmine\player\Player $who) : voidonSlotChange() protected
php
protected function onSlotChange(int $index, \pocketmine\item\Item $before) : voidremove()
php
public function remove(\pocketmine\item\Item $item) : voidremoveAllViewers()
php
public function removeAllViewers() : voidRemoves the inventory window from all players currently viewing it.
removeItem()
php
public function removeItem(\pocketmine\item\Item ...$slots) : arraysetContents()
php
public function setContents(array $items) : voidsetItem()
php
public function setItem(int $index, \pocketmine\item\Item $item) : voidsetMaxStackSize()
php
public function setMaxStackSize(int $size) : voidslotExists()
php
public function slotExists(int $slot) : boolswap()
php
public function swap(int $slot1, int $slot2) : void