ShulkerBoxInventory: avoid usage of legacy ItemIds

This commit is contained in:
Dylan K. Taylor 2022-06-30 19:03:07 +01:00
parent 2a0b500010
commit af8f2c47f3
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -23,9 +23,10 @@ declare(strict_types=1);
namespace pocketmine\block\inventory; namespace pocketmine\block\inventory;
use pocketmine\block\BlockTypeIds;
use pocketmine\inventory\SimpleInventory; use pocketmine\inventory\SimpleInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\ItemIds; use pocketmine\item\ItemBlock;
use pocketmine\network\mcpe\protocol\BlockEventPacket; use pocketmine\network\mcpe\protocol\BlockEventPacket;
use pocketmine\network\mcpe\protocol\types\BlockPosition; use pocketmine\network\mcpe\protocol\types\BlockPosition;
use pocketmine\world\Position; use pocketmine\world\Position;
@ -50,8 +51,11 @@ class ShulkerBoxInventory extends SimpleInventory implements BlockInventory{
} }
public function canAddItem(Item $item) : bool{ public function canAddItem(Item $item) : bool{
if($item->getId() === ItemIds::UNDYED_SHULKER_BOX || $item->getId() === ItemIds::SHULKER_BOX){ if($item instanceof ItemBlock){
return false; $blockTypeId = $item->getBlock()->getTypeId();
if($blockTypeId === BlockTypeIds::SHULKER_BOX || $blockTypeId === BlockTypeIds::DYED_SHULKER_BOX){
return false;
}
} }
return parent::canAddItem($item); return parent::canAddItem($item);
} }