diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index 17ec10dfb..cb1bb478d 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -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(); diff --git a/src/pocketmine/inventory/Inventory.php b/src/pocketmine/inventory/Inventory.php index 7e23b1935..1f1fc266f 100644 --- a/src/pocketmine/inventory/Inventory.php +++ b/src/pocketmine/inventory/Inventory.php @@ -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) *