Clean up ChestInventory handling

longer term I want to rip this crap out completely, but right now this provides minor maintainability benefits, while also making it slightly less nasty to deal with other containers which animate their blocks, such as barrels and shulker boxes.
This commit is contained in:
Dylan K. Taylor
2020-11-16 16:59:19 +00:00
parent b534ae050e
commit 1cf3a500f8
3 changed files with 61 additions and 38 deletions

View File

@ -26,9 +26,7 @@ namespace pocketmine\block\inventory;
use pocketmine\inventory\BaseInventory;
use pocketmine\inventory\InventoryHolder;
use pocketmine\item\Item;
use pocketmine\player\Player;
use pocketmine\world\Position;
use function count;
class DoubleChestInventory extends ChestInventory implements InventoryHolder{
/** @var ChestInventory */
@ -74,19 +72,9 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{
return $result;
}
public function onOpen(Player $who) : void{
parent::onOpen($who);
if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){
$this->right->broadcastBlockEventPacket(true);
}
}
public function onClose(Player $who) : void{
if(count($this->getViewers()) === 1 and $this->right->getHolder()->isValid()){
$this->right->broadcastBlockEventPacket(false);
}
parent::onClose($who);
protected function animateBlock(bool $isOpen) : void{
$this->left->animateBlock($isOpen);
$this->right->animateBlock($isOpen);
}
public function getLeftSide() : ChestInventory{