PocketMine-MP 5.15.1 git-ed158f8a1b0cfe334ac5f45febc0f633602014f2
pocketmine\block\inventory\DoubleChestInventory Class Reference
+ Inheritance diagram for pocketmine\block\inventory\DoubleChestInventory:
+ Collaboration diagram for pocketmine\block\inventory\DoubleChestInventory:

Public Member Functions

 __construct (private ChestInventory $left, private ChestInventory $right)
 
 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)
 
 getHolder ()
 
 getInventory ()
 
 getItem (int $index)
 
 getLeftSide ()
 
 getListeners ()
 
 getMaxStackSize ()
 
 getRightSide ()
 
 getSize ()
 
 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

 animateBlock (bool $isOpen)
 
 getCloseSound ()
 
 getMatchingItemCount (int $slot, Item $test, bool $checkTags)
 
 getOpenSound ()
 
 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
 
array $viewers = []
 

Detailed Description

Definition at line 33 of file DoubleChestInventory.php.

Constructor & Destructor Documentation

◆ __construct()

pocketmine\block\inventory\DoubleChestInventory::__construct ( private ChestInventory  $left,
private ChestInventory  $right 
)

Definition at line 36 of file DoubleChestInventory.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 205 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 135 of file BaseInventory.php.

◆ animateBlock()

pocketmine\block\inventory\DoubleChestInventory::animateBlock ( bool  $isOpen)
protected

Definition at line 106 of file DoubleChestInventory.php.

◆ canAddItem()

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

Checks if a given Item can be added to the inventory

Implements pocketmine\inventory\Inventory.

Reimplemented in pocketmine\block\inventory\ShulkerBoxInventory.

Definition at line 179 of file BaseInventory.php.

◆ clear()

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

Will clear a specific slot

Implements pocketmine\inventory\Inventory.

Definition at line 321 of file BaseInventory.php.

Referenced by pocketmine\inventory\transaction\TransactionBuilderInventory\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 325 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 119 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 147 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 161 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 183 of file BaseInventory.php.

◆ getCloseSound()

pocketmine\block\inventory\DoubleChestInventory::getCloseSound ( )
protected

Definition at line 104 of file DoubleChestInventory.php.

◆ getContents()

pocketmine\block\inventory\DoubleChestInventory::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>

Implements pocketmine\inventory\Inventory.

Definition at line 60 of file DoubleChestInventory.php.

◆ getInventory()

pocketmine\block\inventory\DoubleChestInventory::getInventory ( )

Implements pocketmine\inventory\InventoryHolder.

Definition at line 44 of file DoubleChestInventory.php.

◆ getItem()

pocketmine\block\inventory\DoubleChestInventory::getItem ( int  $index)

Returns the item in the specified slot.

Implements pocketmine\inventory\Inventory.

Definition at line 52 of file DoubleChestInventory.php.

◆ getLeftSide()

pocketmine\block\inventory\DoubleChestInventory::getLeftSide ( )

Definition at line 111 of file DoubleChestInventory.php.

◆ getListeners()

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

Implements pocketmine\inventory\Inventory.

Definition at line 398 of file BaseInventory.php.

◆ getMatchingItemCount()

pocketmine\block\inventory\DoubleChestInventory::getMatchingItemCount ( int  $slot,
Item  $test,
bool  $checkTags 
)
protected

Helper for utility functions which search the inventory. TODO: make this abstract instead of providing a slow default implementation (BC break)

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 88 of file DoubleChestInventory.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 54 of file BaseInventory.php.

◆ getOpenSound()

pocketmine\block\inventory\DoubleChestInventory::getOpenSound ( )
protected

Definition at line 102 of file DoubleChestInventory.php.

◆ getRightSide()

pocketmine\block\inventory\DoubleChestInventory::getRightSide ( )

Definition at line 115 of file DoubleChestInventory.php.

◆ getSize()

pocketmine\block\inventory\DoubleChestInventory::getSize ( )

Returns the number of slots in the inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 48 of file DoubleChestInventory.php.

◆ getViewers()

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

Implements pocketmine\inventory\Inventory.

Definition at line 339 of file BaseInventory.php.

◆ internalSetContents()

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

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 71 of file DoubleChestInventory.php.

◆ internalSetItem()

pocketmine\block\inventory\DoubleChestInventory::internalSetItem ( int  $index,
Item  $item 
)
protected

Reimplemented from pocketmine\inventory\BaseInventory.

Definition at line 56 of file DoubleChestInventory.php.

◆ isSlotEmpty()

pocketmine\block\inventory\DoubleChestInventory::isSlotEmpty ( int  $index)

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 95 of file DoubleChestInventory.php.

◆ onClose()

pocketmine\inventory\BaseInventory::onClose ( Player  $who)
inherited

Implements pocketmine\inventory\Inventory.

Definition at line 359 of file BaseInventory.php.

◆ onContentChange()

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

Reimplemented in pocketmine\inventory\DelegateInventory.

Definition at line 380 of file BaseInventory.php.

◆ onOpen()

pocketmine\inventory\BaseInventory::onOpen ( Player  $who)
inherited

Called when a player opens this inventory.

Implements pocketmine\inventory\Inventory.

Definition at line 355 of file BaseInventory.php.

◆ onSlotChange()

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

Definition at line 363 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 273 of file BaseInventory.php.

◆ removeAllViewers()

pocketmine\inventory\BaseInventory::removeAllViewers ( )
inherited

Removes the inventory window from all players currently viewing it.

Definition at line 346 of file BaseInventory.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 283 of file BaseInventory.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 87 of file BaseInventory.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 64 of file BaseInventory.php.

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

+ Here is the caller graph for this function:

◆ 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 58 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 394 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 329 of file BaseInventory.php.

Member Data Documentation

◆ $listeners

ObjectSet pocketmine\inventory\BaseInventory::$listeners
protectedinherited

Definition at line 48 of file BaseInventory.php.

◆ $maxStackSize

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

Definition at line 41 of file BaseInventory.php.

◆ $viewers

array pocketmine\inventory\BaseInventory::$viewers = []
protectedinherited

Definition at line 43 of file BaseInventory.php.

◆ MAX_STACK

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

Definition at line 34 of file Inventory.php.


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