mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 09:10:00 +00:00
DoubleChestInventory: specialize isSlotEmpty() and getMatchingItemCount()
This commit is contained in:
parent
eb136e60c8
commit
73bf5d4b29
@ -85,6 +85,20 @@ class DoubleChestInventory extends BaseInventory implements BlockInventory, Inve
|
|||||||
$this->right->setContents($rightContents);
|
$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 getOpenSound() : Sound{ return new ChestOpenSound(); }
|
||||||
|
|
||||||
protected function getCloseSound() : Sound{ return new ChestCloseSound(); }
|
protected function getCloseSound() : Sound{ return new ChestCloseSound(); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user