Inventory: added API method isSlotEmpty()

This commit is contained in:
Dylan K. Taylor 2018-03-26 09:24:00 +01:00
parent cf3638ad8d
commit c7e803372c
2 changed files with 13 additions and 0 deletions

View File

@ -237,6 +237,10 @@ abstract class BaseInventory implements Inventory{
return -1;
}
public function isSlotEmpty(int $index) : bool{
return $this->slots[$index] === null or $this->slots[$index]->isNull();
}
public function canAddItem(Item $item) : bool{
$item = clone $item;
$checkDamage = !$item->hasAnyDamageValue();

View File

@ -171,6 +171,15 @@ interface Inventory{
*/
public function firstEmpty() : int;
/**
* Returns whether the given slot is empty.
*
* @param int $index
*
* @return bool
*/
public function isSlotEmpty(int $index) : bool;
/**
* Will remove all the Items that has the same id and metadata (if not null)
*