diff --git a/src/pocketmine/inventory/DoubleChestInventory.php b/src/pocketmine/inventory/DoubleChestInventory.php index 06578e19f..781892640 100644 --- a/src/pocketmine/inventory/DoubleChestInventory.php +++ b/src/pocketmine/inventory/DoubleChestInventory.php @@ -64,7 +64,12 @@ class DoubleChestInventory extends ChestInventory implements InventoryHolder{ } public function setItem(int $index, Item $item, bool $send = true) : bool{ - return $index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send); + $old = $this->getItem($index); + if($index < $this->left->getSize() ? $this->left->setItem($index, $item, $send) : $this->right->setItem($index - $this->left->getSize(), $item, $send)){ + $this->onSlotChange($index, $old, $send); + return true; + } + return false; } public function getContents(bool $includeEmpty = false) : array{ diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index 15ff38580..beb6d1214 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -113,10 +113,14 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ $pair->checkPairing(); } if($this->doubleInventory === null){ - if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly - $this->doubleInventory = new DoubleChestInventory($pair, $this); + if($pair->doubleInventory !== null){ + $this->doubleInventory = $pair->doubleInventory; }else{ - $this->doubleInventory = new DoubleChestInventory($this, $pair); + if(($pair->x + ($pair->z << 15)) > ($this->x + ($this->z << 15))){ //Order them correctly + $this->doubleInventory = new DoubleChestInventory($pair, $this); + }else{ + $this->doubleInventory = new DoubleChestInventory($this, $pair); + } } } }else{