Skip to content

BaseInventory ​

abstract class · pocketmine\inventory\BaseInventory · source

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 $viewers

Methods ​

__construct() ​

php
public function __construct()

addItem() ​

php
public function addItem(\pocketmine\item\Item ...$slots) : array

all() ​

php
public function all(\pocketmine\item\Item $item) : array

canAddItem() ​

php
public function canAddItem(\pocketmine\item\Item $item) : bool

clear() ​

php
public function clear(int $index) : void

clearAll() ​

php
public function clearAll() : void

contains() ​

php
public function contains(\pocketmine\item\Item $item) : bool

first() ​

php
public function first(\pocketmine\item\Item $item, bool $exact = false) : int

firstEmpty() ​

php
public function firstEmpty() : int

getAddableItemQuantity() ​

php
public function getAddableItemQuantity(\pocketmine\item\Item $item) : int

getListeners() ​

php
public function getListeners() : \pocketmine\utils\ObjectSet

getMatchingItemCount() protected ​

php
protected function getMatchingItemCount(int $slot, \pocketmine\item\Item $test, bool $checkTags) : int

Helper 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() : int

getSlotValidators() ​

php
public function getSlotValidators() : \pocketmine\utils\ObjectSet

getViewers() ​

php
public function getViewers() : array

internalSetContents() protected ​

php
abstract protected function internalSetContents(array $items) : void

internalSetItem() protected ​

php
abstract protected function internalSetItem(int $index, \pocketmine\item\Item $item) : void

isSlotEmpty() ​

php
public function isSlotEmpty(int $index) : bool

TODO: 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) : void

onContentChange() protected ​

php
protected function onContentChange(array $itemsBefore) : void

onOpen() ​

php
public function onOpen(\pocketmine\player\Player $who) : void

onSlotChange() protected ​

php
protected function onSlotChange(int $index, \pocketmine\item\Item $before) : void

remove() ​

php
public function remove(\pocketmine\item\Item $item) : void

removeAllViewers() ​

php
public function removeAllViewers() : void

Removes the inventory window from all players currently viewing it.

removeItem() ​

php
public function removeItem(\pocketmine\item\Item ...$slots) : array

setContents() ​

php
public function setContents(array $items) : void

setItem() ​

php
public function setItem(int $index, \pocketmine\item\Item $item) : void

setMaxStackSize() ​

php
public function setMaxStackSize(int $size) : void

slotExists() ​

php
public function slotExists(int $slot) : bool

swap() ​

php
public function swap(int $slot1, int $slot2) : void

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.