DoubleChestInventory: specialize isSlotEmpty() and getMatchingItemCount()

This commit is contained in:
Dylan K. Taylor 2023-04-27 21:17:55 +01:00
parent eb136e60c8
commit 73bf5d4b29
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -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(); }