From e77cd39316999a382a2b197152ef23f6bdde03b4 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 9 Jan 2024 15:55:41 +0000 Subject: [PATCH] ItemBlock: add a workaround for air items with a stack size bigger than 0 In the future we should look into making empty slots be represented by null or a different, special item type, instead of breaking the air block for this purpose. closes #6185 closes #6016 --- src/item/ItemBlock.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/item/ItemBlock.php b/src/item/ItemBlock.php index 11bcb58d3..015c78471 100644 --- a/src/item/ItemBlock.php +++ b/src/item/ItemBlock.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace pocketmine\item; use pocketmine\block\Block; +use pocketmine\block\BlockTypeIds; use pocketmine\data\runtime\RuntimeDataDescriber; /** @@ -58,4 +59,12 @@ final class ItemBlock extends Item{ public function getMaxStackSize() : int{ return $this->block->getMaxStackSize(); } + + public function isNull() : bool{ + //TODO: we really shouldn't need to treat air as a special case here + //this is needed because the "null" empty slot item is represented by an air block, but there's no real reason + //why air should be needed at all. A separate special item type (or actual null) should be used instead, but + //this would cause a lot of BC breaks, so we can't do it yet. + return parent::isNull() || $this->block->getTypeId() === BlockTypeIds::AIR; + } }