From 73bf5d4b29f6e64edc28aee900614b78a62192bb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 27 Apr 2023 21:17:55 +0100 Subject: [PATCH] DoubleChestInventory: specialize isSlotEmpty() and getMatchingItemCount() --- src/block/inventory/DoubleChestInventory.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/block/inventory/DoubleChestInventory.php b/src/block/inventory/DoubleChestInventory.php index 92c75ef9f..8c38e190d 100644 --- a/src/block/inventory/DoubleChestInventory.php +++ b/src/block/inventory/DoubleChestInventory.php @@ -85,6 +85,20 @@ class DoubleChestInventory extends BaseInventory implements BlockInventory, Inve $this->right->setContents($rightContents); } + protected function getMatchingItemCount(int $slot, Item $test, bool $checkDamage, bool $checkTags) : int{ + $leftSize = $this->left->getSize(); + return $slot < $leftSize ? + $this->left->getMatchingItemCount($slot, $test, $checkDamage, $checkTags) : + $this->right->getMatchingItemCount($slot - $leftSize, $test, $checkDamage, $checkTags); + } + + public function isSlotEmpty(int $index) : bool{ + $leftSize = $this->left->getSize(); + return $index < $leftSize ? + $this->left->isSlotEmpty($index) : + $this->right->isSlotEmpty($index - $leftSize); + } + protected function getOpenSound() : Sound{ return new ChestOpenSound(); } protected function getCloseSound() : Sound{ return new ChestCloseSound(); }