PocketMine-MP 5.33.2 git-1133d49c924b4358c79d44eeb97dcbf56cb4d1eb
Loading...
Searching...
No Matches
pocketmine\inventory\ArmorInventory Class Reference
+ Inheritance diagram for pocketmine\inventory\ArmorInventory:
+ Collaboration diagram for pocketmine\inventory\ArmorInventory:

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)
 
 getBoots ()
 
 getChestplate ()
 
 getContents (bool $includeEmpty=false)
 
 getHelmet ()
 
 getItem (int $index)
 
 getLeggings ()
 
 getListeners ()
 
 getMatchingItemCount (int $slot, Item $test, bool $checkTags)
 
 getMaxStackSize ()
 
 getSize ()
 
 getSlotValidators ()
 
 getViewers ()
 
 isSlotEmpty (int $index)
 
 onClose (InventoryWindow $window)
 
 onOpen (InventoryWindow $window)
 
 remove (Item $item)
 
 removeAllWindows ()
 
 removeItem (Item ... $slots)
 
 setBoots (Item $boots)
 
 setChestplate (Item $chestplate)
 
 setContents (array $items)
 
 setHelmet (Item $helmet)
 
 setItem (int $index, Item $item)
 
 setLeggings (Item $leggings)
 
 setMaxStackSize (int $size)
 
 slotExists (int $slot)
 
 swap (int $slot1, int $slot2)
 

Public Attributes

const MAX_STACK = 64
 
const SLOT_CHEST = 1
 
const SLOT_FEET = 3
 
const SLOT_HEAD = 0
 
const SLOT_LEGS = 2
 

Protected Member Functions

 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
 
SplFixedArray $slots
 
ObjectSet $validators
 
array $windows = []
 

Detailed Description

Definition at line 33 of file ArmorInventory.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\inventory\ArmorInventory::__construct ( )

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 39 of file ArmorInventory.php.

Member Function Documentation

◆ addItem()

pocketmine\inventory\BaseInventory::addItem ( Item ... $slots)
inherited

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[]

Implements pocketmine\inventory\Inventory.

Definition at line 192 of file BaseInventory.php.

◆ all()

pocketmine\inventory\BaseInventory::all ( Item $item)
inherited

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>

Implements pocketmine\inventory\Inventory.

Definition at line 122 of file BaseInventory.php.

◆ canAddItem()

pocketmine\inventory\BaseInventory::canAddItem ( Item $item)
inherited

Checks if a given Item can be added to the inventory

Implements pocketmine\inventory\Inventory.

Definition at line 166 of file BaseInventory.php.

◆ clear()

pocketmine\inventory\BaseInventory::clear ( int $index)
inherited

Will clear a specific slot

Implements pocketmine\inventory\Inventory.

Definition at line 306 of file BaseInventory.php.

Referenced by pocketmine\inventory\transaction\SlotChangeActionBuilder\internalSetContents().

+ Here is the caller graph for this function:

◆ clearAll()

pocketmine\inventory\BaseInventory::clearAll ( )
inherited

Clears all the slots

Implements pocketmine\inventory\Inventory.

Definition at line 310 of file BaseInventory.php.

◆ contains()

pocketmine\inventory\BaseInventory::contains ( Item $item)
inherited

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 106 of file BaseInventory.php.

◆ first()

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

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 134 of file BaseInventory.php.

◆ firstEmpty()

pocketmine\inventory\BaseInventory::firstEmpty ( )
inherited

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

Implements pocketmine\inventory\Inventory.

Definition at line 148 of file BaseInventory.php.

◆ getAddableItemQuantity()

pocketmine\inventory\BaseInventory::getAddableItemQuantity ( Item $item)
inherited

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

Implements pocketmine\inventory\Inventory.

Definition at line 170 of file BaseInventory.php.

◆ getBoots()

pocketmine\inventory\ArmorInventory::getBoots ( )

Definition at line 57 of file ArmorInventory.php.

◆ getChestplate()

pocketmine\inventory\ArmorInventory::getChestplate ( )

Definition at line 49 of file ArmorInventory.php.

◆ getContents()

pocketmine\inventory\SimpleInventory::getContents ( bool $includeEmpty = false)
inherited
Returns
Item[] @phpstan-return array<int, Item>

Implements pocketmine\inventory\Inventory.

Definition at line 73 of file SimpleInventory.php.

◆ getHelmet()

pocketmine\inventory\ArmorInventory::getHelmet ( )

Definition at line 45 of file ArmorInventory.php.

◆ getItem()

pocketmine\inventory\SimpleInventory::getItem ( int $index)
inherited

Returns the item in the specified slot.

Implements pocketmine\inventory\Inventory.

Definition at line 61 of file SimpleInventory.php.

◆ getLeggings()

pocketmine\inventory\ArmorInventory::getLeggings ( )

Definition at line 53 of file ArmorInventory.php.

◆ getListeners()

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

Implements pocketmine\inventory\Inventory.

Definition at line 341 of file BaseInventory.php.

◆ getMatchingItemCount()

pocketmine\inventory\SimpleInventory::getMatchingItemCount ( int $slot,
Item $test,
bool $checkTags )
inherited

Returns the number of items in the inventory that match the given item.

Parameters
bool$checkTagsIf true, the NBT of the items will also be checked and must be the same to be counted.

Implements pocketmine\inventory\Inventory.

Definition at line 97 of file SimpleInventory.php.

◆ getMaxStackSize()

pocketmine\inventory\BaseInventory::getMaxStackSize ( )
inherited

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.

Definition at line 55 of file BaseInventory.php.

◆ getSize()

pocketmine\inventory\SimpleInventory::getSize ( )
inherited

Returns the size of the inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 57 of file SimpleInventory.php.

◆ getSlotValidators()

pocketmine\inventory\BaseInventory::getSlotValidators ( )
inherited

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 345 of file BaseInventory.php.

◆ getViewers()

pocketmine\inventory\SimpleInventory::getViewers ( )
inherited
Returns
Player[]

Implements pocketmine\inventory\Inventory.

Definition at line 109 of file SimpleInventory.php.

◆ internalSetContents()

pocketmine\inventory\SimpleInventory::internalSetContents ( array $items)
protectedinherited
Parameters
Item[]$items@phpstan-param array<int, Item> $items

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 87 of file SimpleInventory.php.

◆ internalSetItem()

pocketmine\inventory\SimpleInventory::internalSetItem ( int $index,
Item $item )
protectedinherited

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 65 of file SimpleInventory.php.

◆ isSlotEmpty()

pocketmine\inventory\SimpleInventory::isSlotEmpty ( int $index)
inherited

TODO: make this abstract and force implementations to implement it properly (BC break) This default implementation works, but is slow.

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 102 of file SimpleInventory.php.

◆ onClose()

pocketmine\inventory\SimpleInventory::onClose ( InventoryWindow $window)
inherited

Implements pocketmine\inventory\Inventory.

Definition at line 136 of file SimpleInventory.php.

◆ onContentChange()

pocketmine\inventory\BaseInventory::onContentChange ( array $itemsBefore)
protectedinherited
Parameters
Item[]$itemsBefore@phpstan-param array<int, Item> $itemsBefore

Definition at line 331 of file BaseInventory.php.

◆ onOpen()

pocketmine\inventory\SimpleInventory::onOpen ( InventoryWindow $window)
inherited

Called when a player opens this inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 132 of file SimpleInventory.php.

◆ onSlotChange()

pocketmine\inventory\BaseInventory::onSlotChange ( int $index,
Item $before )
protectedinherited

Definition at line 321 of file BaseInventory.php.

◆ remove()

pocketmine\inventory\BaseInventory::remove ( Item $item)
inherited

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 260 of file BaseInventory.php.

◆ removeAllWindows()

pocketmine\inventory\SimpleInventory::removeAllWindows ( )
inherited

Gets rid of any inventory windows known to be referencing this inventory

Implements pocketmine\inventory\Inventory.

Definition at line 122 of file SimpleInventory.php.

◆ removeItem()

pocketmine\inventory\BaseInventory::removeItem ( Item ... $slots)
inherited

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[]

Implements pocketmine\inventory\Inventory.

Definition at line 270 of file BaseInventory.php.

◆ setBoots()

pocketmine\inventory\ArmorInventory::setBoots ( Item $boots)

Definition at line 73 of file ArmorInventory.php.

◆ setChestplate()

pocketmine\inventory\ArmorInventory::setChestplate ( Item $chestplate)

Definition at line 65 of file ArmorInventory.php.

◆ setContents()

pocketmine\inventory\BaseInventory::setContents ( array $items)
inherited
Parameters
Item[]$items@phpstan-param array<int, Item> $items

Implements pocketmine\inventory\Inventory.

Definition at line 88 of file BaseInventory.php.

◆ setHelmet()

pocketmine\inventory\ArmorInventory::setHelmet ( Item $helmet)

Definition at line 61 of file ArmorInventory.php.

◆ setItem()

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

Puts an Item in a slot.

Implements pocketmine\inventory\Inventory.

Reimplemented in pocketmine\crafting\CraftingGrid.

Definition at line 65 of file BaseInventory.php.

Referenced by pocketmine\inventory\transaction\SlotChangeActionBuilder\internalSetContents().

+ Here is the caller graph for this function:

◆ setLeggings()

pocketmine\inventory\ArmorInventory::setLeggings ( Item $leggings)

Definition at line 69 of file ArmorInventory.php.

◆ setMaxStackSize()

pocketmine\inventory\BaseInventory::setMaxStackSize ( int $size)
inherited

Sets the maximum stack size for items in this inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 59 of file BaseInventory.php.

◆ slotExists()

pocketmine\inventory\BaseInventory::slotExists ( int $slot)
inherited

Returns whether the specified slot exists in the inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 337 of file BaseInventory.php.

◆ swap()

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

Swaps the specified slots.

Implements pocketmine\inventory\Inventory.

Definition at line 314 of file BaseInventory.php.

Member Data Documentation

◆ $listeners

ObjectSet pocketmine\inventory\BaseInventory::$listeners
protectedinherited

Definition at line 46 of file BaseInventory.php.

◆ $maxStackSize

int pocketmine\inventory\BaseInventory::$maxStackSize = Inventory::MAX_STACK
protectedinherited

Definition at line 41 of file BaseInventory.php.

◆ $slots

SplFixedArray pocketmine\inventory\SimpleInventory::$slots
protectedinherited

Definition at line 41 of file SimpleInventory.php.

◆ $validators

ObjectSet pocketmine\inventory\BaseInventory::$validators
protectedinherited

@phpstan-var SlotValidators

Definition at line 48 of file BaseInventory.php.

◆ $windows

array pocketmine\inventory\SimpleInventory::$windows = []
protectedinherited

Definition at line 47 of file SimpleInventory.php.

◆ MAX_STACK

const pocketmine\inventory\Inventory::MAX_STACK = 64
inherited

Definition at line 35 of file Inventory.php.

◆ SLOT_CHEST

const pocketmine\inventory\ArmorInventory::SLOT_CHEST = 1

Definition at line 35 of file ArmorInventory.php.

◆ SLOT_FEET

const pocketmine\inventory\ArmorInventory::SLOT_FEET = 3

Definition at line 37 of file ArmorInventory.php.

◆ SLOT_HEAD

const pocketmine\inventory\ArmorInventory::SLOT_HEAD = 0

Definition at line 34 of file ArmorInventory.php.

◆ SLOT_LEGS

const pocketmine\inventory\ArmorInventory::SLOT_LEGS = 2

Definition at line 36 of file ArmorInventory.php.


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