diff --git a/src/pocketmine/inventory/BaseInventory.php b/src/pocketmine/inventory/BaseInventory.php index ebe147bdd..e87105e43 100644 --- a/src/pocketmine/inventory/BaseInventory.php +++ b/src/pocketmine/inventory/BaseInventory.php @@ -224,11 +224,9 @@ abstract class BaseInventory implements Inventory{ public function canAddItem(Item $item) : bool{ $item = clone $item; - $checkDamage = !$item->hasAnyDamageValue(); - $checkTags = $item->hasNamedTag(); for($i = 0, $size = $this->getSize(); $i < $size; ++$i){ $slot = $this->getItem($i); - if($item->equals($slot, $checkDamage, $checkTags)){ + if($item->equals($slot)){ if(($diff = $slot->getMaxStackSize() - $slot->getCount()) > 0){ $item->setCount($item->getCount() - $diff); } diff --git a/tests/phpunit/inventory/BaseInventoryTest.php b/tests/phpunit/inventory/BaseInventoryTest.php new file mode 100644 index 000000000..ade55f317 --- /dev/null +++ b/tests/phpunit/inventory/BaseInventoryTest.php @@ -0,0 +1,59 @@ +setCustomName("TEST"); + + $inv->addItem(clone $item1); + self::assertFalse($inv->canAddItem($item2), "Item WITHOUT userdata should not stack with item WITH userdata"); + self::assertNotEmpty($inv->addItem($item2)); + + $inv->clearAll(); + self::assertEmpty($inv->getContents()); + + $inv->addItem(clone $item2); + self::assertFalse($inv->canAddItem($item1), "Item WITH userdata should not stack with item WITHOUT userdata"); + self::assertNotEmpty($inv->addItem($item1)); + } +}