holder = $this->left->getHolder(); parent::__construct(); } public function getInventory() : self{ return $this; } public function getSize() : int{ return $this->left->getSize() + $this->right->getSize(); } public function getItem(int $index) : Item{ return $index < $this->left->getSize() ? $this->left->getItem($index) : $this->right->getItem($index - $this->left->getSize()); } protected function internalSetItem(int $index, Item $item) : void{ $index < $this->left->getSize() ? $this->left->setItem($index, $item) : $this->right->setItem($index - $this->left->getSize(), $item); } public function getContents(bool $includeEmpty = false) : array{ $result = $this->left->getContents($includeEmpty); $leftSize = $this->left->getSize(); foreach($this->right->getContents($includeEmpty) as $i => $item){ $result[$i + $leftSize] = $item; } return $result; } protected function internalSetContents(array $items) : void{ $leftSize = $this->left->getSize(); $leftContents = []; $rightContents = []; foreach($items as $i => $item){ if($i < $this->left->getSize()){ $leftContents[$i] = $item; }else{ $rightContents[$i - $leftSize] = $item; } } $this->left->setContents($leftContents); $this->right->setContents($rightContents); } protected function getOpenSound() : Sound{ return new ChestOpenSound(); } protected function getCloseSound() : Sound{ return new ChestCloseSound(); } protected function animateBlock(bool $isOpen) : void{ $this->left->animateBlock($isOpen); $this->right->animateBlock($isOpen); } public function getLeftSide() : ChestInventory{ return $this->left; } public function getRightSide() : ChestInventory{ return $this->right; } }