PocketMine
Inventory Interface Reference
Inheritance diagram for Inventory:
BaseInventory ContainerInventory CraftingInventory PlayerInventory AnvilInventory ChestInventory CustomInventory EnchantInventory FurnaceInventory DoubleChestInventory

Public Member Functions

 getSize ()
 
 getMaxStackSize ()
 
 setMaxStackSize ($size)
 
 getName ()
 
 getTitle ()
 
 getItem ($index)
 
 setItem ($index, Item $item)
 
 addItem (...$slots)
 
 canAddItem (Item $item)
 
 removeItem (...$slots)
 
 getContents ()
 
 setContents (array $items)
 
 sendContents ($target)
 
 sendSlot ($index, $target)
 
 contains (Item $item)
 
 all (Item $item)
 
 first (Item $item)
 
 firstEmpty ()
 
 remove (Item $item)
 
 clear ($index)
 
 clearAll ()
 
 getViewers ()
 
 getType ()
 
 getHolder ()
 
 onOpen (Player $who)
 
 open (Player $who)
 
 close (Player $who)
 
 onClose (Player $who)
 
 onSlotChange ($index, $before)
 

Data Fields

const MAX_STACK = 64
 

Member Function Documentation

addItem (   $slots)

Stores the given Items in the inventory. This will try to fill existing stacks and empty slots as well as it can.

Returns the Items that did not fit.

Parameters
Item...$item
Returns
Item[]
all ( Item  $item)

Will return all the Items that has the same id and metadata (if not null). Won't check amount

Parameters
Item$item
Returns
Item[]

Implemented in BaseInventory.

canAddItem ( Item  $item)

Checks if a given Item can be added to the inventory

Parameters
Item$item
Returns
bool

Implemented in BaseInventory.

clear (   $index)

Will clear a specific slot

Parameters
int$index
Returns
bool

Implemented in BaseInventory, PlayerInventory, and DoubleChestInventory.

clearAll ( )

Clears all the slots

Implemented in BaseInventory, and PlayerInventory.

contains ( Item  $item)

Checks if the inventory contains any Item with the same material data. It will check id, amount, and metadata (if not null)

Parameters
Item$item
Returns
bool

Implemented in BaseInventory.

first ( Item  $item)

Will return the first slot has the same id and metadata (if not null) as the Item. -1 if not found, will check amount

Parameters
Item$item
Returns
int

Implemented in BaseInventory.

firstEmpty ( )

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

Returns
int

Implemented in BaseInventory.

getContents ( )
Returns
Item[]

Implemented in BaseInventory, and DoubleChestInventory.

getItem (   $index)
Parameters
int$index
Returns
Item

Implemented in BaseInventory, and DoubleChestInventory.

getType ( )
Returns
InventoryType

Implemented in BaseInventory.

getViewers ( )

Gets all the Players viewing the inventory Players will view their inventory at all times, even when not open.

Returns
Player[]

Implemented in BaseInventory.

onOpen ( Player  $who)
onSlotChange (   $index,
  $before 
)
Parameters
int$index
Item$before

Implemented in BaseInventory, PlayerInventory, and FurnaceInventory.

open ( Player  $who)

Tries to open the inventory to a player

Parameters
Player$who
Returns
bool

Implemented in BaseInventory.

remove ( Item  $item)

Will remove all the Items that has the same id and metadata (if not null)

Parameters
Item$item

Implemented in BaseInventory.

removeItem (   $slots)

Removes the given Item from the inventory. It will return the Items that couldn't be removed.

Parameters
Item...$item
Returns
Item[]
sendContents (   $target)
Parameters
Player|Player[]$target

Implemented in BaseInventory, and PlayerInventory.

sendSlot (   $index,
  $target 
)
Parameters
int$index
Player|Player[]$target

Implemented in BaseInventory.

setContents ( array  $items)
Parameters
Item[]$items

Implemented in BaseInventory, and DoubleChestInventory.

setItem (   $index,
Item  $item 
)

Puts an Item in a slot. If a plugin refuses the update or $index is invalid, it'll return false If a source Player is specified, it won't send a Inventory update to it

Parameters
int$index
Item$item
Returns
bool

Implemented in PlayerInventory, BaseInventory, and DoubleChestInventory.

setMaxStackSize (   $size)
Parameters
int$size

Implemented in BaseInventory.


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