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

Public Member Functions

 __construct (InventoryHolder $holder, InventoryType $type, array $items=[], $overrideSize=null, $overrideTitle=null)
 
 getSize ()
 
 setSize ($size)
 
 getMaxStackSize ()
 
 getName ()
 
 getTitle ()
 
 getItem ($index)
 
 getContents ()
 
 setContents (array $items)
 
 setItem ($index, Item $item)
 
 contains (Item $item)
 
 all (Item $item)
 
 remove (Item $item)
 
 first (Item $item)
 
 firstEmpty ()
 
 canAddItem (Item $item)
 
 clear ($index)
 
 clearAll ()
 
 getViewers ()
 
 getHolder ()
 
 setMaxStackSize ($size)
 
 open (Player $who)
 
 close (Player $who)
 
 onOpen (Player $who)
 
 onClose (Player $who)
 
 onSlotChange ($index, $before)
 
 sendContents ($target)
 
 sendSlot ($index, $target)
 
 getType ()
 
- Public Member Functions inherited from Inventory
 addItem (...$slots)
 
 removeItem (...$slots)
 

Protected Attributes

 $type
 
 $maxStackSize = Inventory::MAX_STACK
 
 $size
 
 $name
 
 $title
 
 $slots = []
 
 $viewers = []
 
 $holder
 

Additional Inherited Members

- Data Fields inherited from Inventory
const MAX_STACK = 64
 

Constructor & Destructor Documentation

__construct ( InventoryHolder  $holder,
InventoryType  $type,
array  $items = [],
  $overrideSize = null,
  $overrideTitle = null 
)
Parameters
InventoryHolder$holder
InventoryType$type
Item[]$items
int$overrideSize
string$overrideTitle

Member Function Documentation

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

Implements Inventory.

canAddItem ( Item  $item)

Checks if a given Item can be added to the inventory

Parameters
Item$item
Returns
bool

Implements Inventory.

clear (   $index)

Will clear a specific slot

Parameters
int$index
Returns
bool

Implements Inventory.

clearAll ( )

Clears all the slots

Implements Inventory.

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

Implements Inventory.

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

Implements Inventory.

firstEmpty ( )

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

Returns
int

Implements Inventory.

getContents ( )
Returns
Item[]

Implements Inventory.

getHolder ( )
Returns
InventoryHolder

Implements Inventory.

getItem (   $index)
Parameters
int$index
Returns
Item

Implements Inventory.

getType ( )
Returns
InventoryType

Implements Inventory.

getViewers ( )
Returns
Player[]

Implements Inventory.

onClose ( Player  $who)
Parameters
Player$who

Implements Inventory.

onOpen ( Player  $who)
Parameters
Player$who

Implements Inventory.

onSlotChange (   $index,
  $before 
)
Parameters
int$index
Item$before

Implements Inventory.

open ( Player  $who)

Tries to open the inventory to a player

Parameters
Player$who
Returns
bool

Implements Inventory.

remove ( Item  $item)

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

Parameters
Item$item

Implements Inventory.

sendContents (   $target)
Parameters
Player|Player[]$target

Implements Inventory.

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

Implements Inventory.

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

Implements Inventory.

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

Implements Inventory.

setMaxStackSize (   $size)
Parameters
int$size

Implements Inventory.


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