PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
|
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 () | |
getSlotValidators () | |
getViewers () | |
isSlotEmpty (int $index) | |
onClose (Player $who) | |
onOpen (Player $who) | |
remove (Item $item) | |
removeAllViewers () | |
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 |
Protected Member Functions | |
getMatchingItemCount (int $slot, Item $test, bool $checkTags) | |
internalSetContents (array $items) | |
internalSetItem (int $index, Item $item) | |
onContentChange (array $itemsBefore) | |
onSlotChange (int $index, Item $before) | |
Protected Attributes | |
ObjectSet | $listeners |
int | $maxStackSize = Inventory::MAX_STACK |
ObjectSet | $validators |
array | $viewers = [] |
This class provides everything needed to implement an inventory, minus the underlying storage system.
@phpstan-import-type SlotValidators from SlotValidatedInventory
Definition at line 42 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::__construct | ( | ) |
Definition at line 57 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 213 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 143 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::canAddItem | ( | Item | $item | ) |
Checks if a given Item can be added to the inventory
Implements pocketmine\inventory\Inventory.
Reimplemented in pocketmine\block\inventory\ShulkerBoxInventory.
Definition at line 187 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::clear | ( | int | $index | ) |
Will clear a specific slot
Implements pocketmine\inventory\Inventory.
Definition at line 327 of file BaseInventory.php.
Referenced by pocketmine\inventory\transaction\TransactionBuilderInventory\internalSetContents().
pocketmine\inventory\BaseInventory::clearAll | ( | ) |
Clears all the slots
Implements pocketmine\inventory\Inventory.
Definition at line 331 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 127 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 155 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::firstEmpty | ( | ) |
Returns the first empty slot, or -1 if not found
Implements pocketmine\inventory\Inventory.
Definition at line 169 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::getAddableItemQuantity | ( | Item | $item | ) |
Returns how many items from the given itemstack can be added to this inventory.
Implements pocketmine\inventory\Inventory.
Definition at line 191 of file BaseInventory.php.
|
inherited |
Returns an array of all the itemstacks in the inventory, indexed by their slot number. Empty slots are not included unless includeEmpty is true.
Implemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, pocketmine\inventory\SimpleInventory, and pocketmine\inventory\transaction\TransactionBuilderInventory.
|
inherited |
Returns the item in the specified slot.
Implemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, pocketmine\inventory\SimpleInventory, and pocketmine\inventory\transaction\TransactionBuilderInventory.
pocketmine\inventory\BaseInventory::getListeners | ( | ) |
Implements pocketmine\inventory\Inventory.
Definition at line 404 of file BaseInventory.php.
|
protected |
Helper for utility functions which search the inventory. TODO: make this abstract instead of providing a slow default implementation (BC break)
Reimplemented in pocketmine\block\inventory\DoubleChestInventory, and pocketmine\inventory\SimpleInventory.
Definition at line 122 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Reimplemented in pocketmine\block\inventory\CampfireInventory.
Definition at line 62 of file BaseInventory.php.
|
inherited |
Returns the number of slots in the inventory.
Implemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, pocketmine\inventory\SimpleInventory, and pocketmine\inventory\transaction\TransactionBuilderInventory.
pocketmine\inventory\BaseInventory::getSlotValidators | ( | ) |
Returns a set of validators that will be used to determine whether an item can be placed in a particular slot. All validators need to return null for the transaction to be allowed. If one of the validators returns an exception, the transaction will be cancelled.
There is no guarantee that the validators will be called in any particular order.
@phpstan-return SlotValidators
Implements pocketmine\inventory\SlotValidatedInventory.
Definition at line 408 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::getViewers | ( | ) |
Implements pocketmine\inventory\Inventory.
Definition at line 345 of file BaseInventory.php.
|
abstractprotected |
Item[] | $items | @phpstan-param array<int, Item> $items |
Reimplemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, pocketmine\inventory\SimpleInventory, and pocketmine\inventory\transaction\TransactionBuilderInventory.
pocketmine\inventory\BaseInventory::isSlotEmpty | ( | int | $index | ) |
TODO: make this abstract and force implementations to implement it properly (BC break) This default implementation works, but is slow.
Implements pocketmine\inventory\Inventory.
Reimplemented in pocketmine\block\inventory\DoubleChestInventory, pocketmine\inventory\DelegateInventory, and pocketmine\inventory\SimpleInventory.
Definition at line 183 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::onClose | ( | Player | $who | ) |
Implements pocketmine\inventory\Inventory.
Definition at line 365 of file BaseInventory.php.
|
protected |
Item[] | $itemsBefore | @phpstan-param array<int, Item> $itemsBefore |
Reimplemented in pocketmine\inventory\DelegateInventory.
Definition at line 386 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::onOpen | ( | Player | $who | ) |
Called when a player opens this inventory.
Implements pocketmine\inventory\Inventory.
Definition at line 361 of file BaseInventory.php.
|
protected |
Definition at line 369 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 281 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::removeAllViewers | ( | ) |
Removes the inventory window from all players currently viewing it.
Definition at line 352 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::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.
Implements pocketmine\inventory\Inventory.
Definition at line 291 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::setContents | ( | array | $items | ) |
Item[] | $items | @phpstan-param array<int, Item> $items |
Implements pocketmine\inventory\Inventory.
Definition at line 95 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::setItem | ( | int | $index, |
Item | $item ) |
Puts an Item in a slot.
Implements pocketmine\inventory\Inventory.
Reimplemented in pocketmine\crafting\CraftingGrid.
Definition at line 72 of file BaseInventory.php.
Referenced by pocketmine\inventory\transaction\TransactionBuilderInventory\internalSetContents().
pocketmine\inventory\BaseInventory::setMaxStackSize | ( | int | $size | ) |
Sets the maximum stack size for items in this inventory.
Implements pocketmine\inventory\Inventory.
Definition at line 66 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::slotExists | ( | int | $slot | ) |
Returns whether the specified slot exists in the inventory.
Implements pocketmine\inventory\Inventory.
Definition at line 400 of file BaseInventory.php.
pocketmine\inventory\BaseInventory::swap | ( | int | $slot1, |
int | $slot2 ) |
Swaps the specified slots.
Implements pocketmine\inventory\Inventory.
Definition at line 335 of file BaseInventory.php.
|
protected |
Definition at line 53 of file BaseInventory.php.
|
protected |
Definition at line 43 of file BaseInventory.php.
|
protected |
@phpstan-var SlotValidators
Definition at line 55 of file BaseInventory.php.
|
protected |
Definition at line 48 of file BaseInventory.php.
|
inherited |
Definition at line 34 of file Inventory.php.