DoubleChestInventory
extends BaseInventory
in package
implements
BlockInventory, InventoryHolder
Uses
AnimatedBlockInventoryTrait
This class provides everything needed to implement an inventory, minus the underlying storage system.
Interfaces, Classes, Traits and Enums
Table of Contents
- $listeners : array<string|int, InventoryListener>|ObjectSet
- $maxStackSize : int
- $viewers : array<string|int, Player>
- $left : ChestInventory
- $right : ChestInventory
- __construct() : mixed
- addItem() : array<string|int, Item>
- Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
- all() : array<string|int, Item>
- Will return all the Items that has the same id and metadata (if not null).
- canAddItem() : bool
- Checks if a given Item can be added to the inventory
- clear() : void
- Will clear a specific slot
- clearAll() : void
- Clears all the slots
- contains() : bool
- Checks if the inventory contains any Item with the same material data.
- first() : int
- Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.
- firstEmpty() : int
- Returns the first empty slot, or -1 if not found
- getAddableItemQuantity() : int
- Returns how many items from the given itemstack can be added to this inventory.
- getContents() : array<string|int, mixed>
- getInventory() : Inventory
- Get the object related inventory
- getItem() : Item
- getLeftSide() : ChestInventory
- getListeners() : array<string|int, InventoryListener>|ObjectSet
- getMaxStackSize() : int
- getRightSide() : ChestInventory
- getSize() : int
- getViewerCount() : int
- getViewers() : array<string|int, Player>
- Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
- isSlotEmpty() : bool
- Returns whether the given slot is empty.
- onClose() : void
- onOpen() : void
- Called when a player opens this inventory.
- remove() : void
- Will remove all the Items that has the same id and metadata (if not null)
- removeAllViewers() : void
- Removes the inventory window from all players currently viewing it.
- removeItem() : array<string|int, Item>
- Removes the given Item from the inventory.
- setContents() : void
- setItem() : void
- Puts an Item in a slot.
- setMaxStackSize() : void
- slotExists() : bool
- Returns whether the specified slot exists in the inventory.
- swap() : void
- Swaps the specified slots.
- animateBlock() : void
- getCloseSound() : Sound
- getOpenSound() : Sound
- internalSetContents() : void
- internalSetItem() : void
- onContentChange() : void
- onSlotChange() : void
- internalAddItem() : Item
Properties
$listeners
protected
array<string|int, InventoryListener>|ObjectSet
$listeners
Tags
$maxStackSize
protected
int
$maxStackSize
= \pocketmine\inventory\Inventory::MAX_STACK
$viewers
protected
array<string|int, Player>
$viewers
= []
$left
private
ChestInventory
$left
$right
private
ChestInventory
$right
Methods
__construct()
public
__construct(ChestInventory $left, ChestInventory $right) : mixed
Parameters
- $left : ChestInventory
- $right : ChestInventory
Return values
mixed —addItem()
Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.
public
addItem(Item ...$slots) : array<string|int, Item>
Returns the Items that did not fit.
Parameters
- $slots : Item
Return values
array<string|int, Item> —all()
Will return all the Items that has the same id and metadata (if not null).
public
all(Item $item) : array<string|int, Item>
Won't check amount
Parameters
- $item : Item
Return values
array<string|int, Item> —canAddItem()
Checks if a given Item can be added to the inventory
public
canAddItem(Item $item) : bool
Parameters
- $item : Item
Return values
bool —clear()
Will clear a specific slot
public
clear(int $index) : void
Parameters
- $index : int
Return values
void —clearAll()
Clears all the slots
public
clearAll() : void
Return values
void —contains()
Checks if the inventory contains any Item with the same material data.
public
contains(Item $item) : bool
It will check id, amount, and metadata (if not null)
Parameters
- $item : Item
Return values
bool —first()
Returns the first slot number containing an item with the same ID, damage (if not any-damage), NBT (if not empty) and count >= to the count of the specified item stack.
public
first(Item $item[, bool $exact = false ]) : int
If $exact is true, only items with equal ID, damage, NBT and count will match.
Parameters
- $item : Item
- $exact : bool = false
Return values
int —firstEmpty()
Returns the first empty slot, or -1 if not found
public
firstEmpty() : int
Return values
int —getAddableItemQuantity()
Returns how many items from the given itemstack can be added to this inventory.
public
getAddableItemQuantity(Item $item) : int
Parameters
- $item : Item
Return values
int —getContents()
public
getContents([bool $includeEmpty = false ]) : array<string|int, mixed>
Parameters
- $includeEmpty : bool = false
Return values
array<string|int, mixed> —getInventory()
Get the object related inventory
public
getInventory() : Inventory
Return values
Inventory —getItem()
public
getItem(int $index) : Item
Parameters
- $index : int
Return values
Item —getLeftSide()
public
getLeftSide() : ChestInventory
Return values
ChestInventory —getListeners()
public
getListeners() : array<string|int, InventoryListener>|ObjectSet
Return values
array<string|int, InventoryListener>|ObjectSet —getMaxStackSize()
public
getMaxStackSize() : int
Return values
int —getRightSide()
public
getRightSide() : ChestInventory
Return values
ChestInventory —getSize()
public
getSize() : int
Return values
int —getViewerCount()
public
getViewerCount() : int
Return values
int —getViewers()
Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.
public
getViewers() : array<string|int, Player>
Return values
array<string|int, Player> —isSlotEmpty()
Returns whether the given slot is empty.
public
isSlotEmpty(int $index) : bool
Parameters
- $index : int
Return values
bool —onClose()
public
onClose(Player $who) : void
Parameters
- $who : Player
Return values
void —onOpen()
Called when a player opens this inventory.
public
onOpen(Player $who) : void
Parameters
- $who : Player
Return values
void —remove()
Will remove all the Items that has the same id and metadata (if not null)
public
remove(Item $item) : void
Parameters
- $item : Item
Return values
void —removeAllViewers()
Removes the inventory window from all players currently viewing it.
public
removeAllViewers() : void
Return values
void —removeItem()
Removes the given Item from the inventory.
public
removeItem(Item ...$slots) : array<string|int, Item>
It will return the Items that couldn't be removed.
Parameters
- $slots : Item
Return values
array<string|int, Item> —setContents()
public
setContents(array<string|int, Item> $items) : void
Parameters
- $items : array<string|int, Item>
Return values
void —setItem()
Puts an Item in a slot.
public
setItem(int $index, Item $item) : void
Parameters
- $index : int
- $item : Item
Return values
void —setMaxStackSize()
public
setMaxStackSize(int $size) : void
Parameters
- $size : int
Return values
void —slotExists()
Returns whether the specified slot exists in the inventory.
public
slotExists(int $slot) : bool
Parameters
- $slot : int
Return values
bool —swap()
Swaps the specified slots.
public
swap(int $slot1, int $slot2) : void
Parameters
- $slot1 : int
- $slot2 : int
Return values
void —animateBlock()
protected
animateBlock(bool $isOpen) : void
Parameters
- $isOpen : bool
Return values
void —getCloseSound()
protected
getCloseSound() : Sound
Return values
Sound —getOpenSound()
protected
getOpenSound() : Sound
Return values
Sound —internalSetContents()
protected
internalSetContents(array<string|int, mixed> $items) : void
Parameters
- $items : array<string|int, mixed>
Return values
void —internalSetItem()
protected
internalSetItem(int $index, Item $item) : void
Parameters
- $index : int
- $item : Item
Return values
void —onContentChange()
protected
onContentChange(array<string|int, Item> $itemsBefore) : void
Parameters
- $itemsBefore : array<string|int, Item>
Tags
Return values
void —onSlotChange()
protected
onSlotChange(int $index, Item $before) : void
Parameters
- $index : int
- $before : Item
Return values
void —internalAddItem()
private
internalAddItem(Item $slot) : Item
Parameters
- $slot : Item