From d7be2ce4394e910c7911a0639525b52f5483f472 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 21 Dec 2014 14:29:18 +0100 Subject: [PATCH] Added Chest recreation on imported levels --- src/pocketmine/tile/Chest.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index f729127ad..e6725f5f7 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -170,6 +170,10 @@ class Chest extends Spawnable implements InventoryHolder, Container{ protected function checkPairing(){ if(($pair = $this->getPair()) instanceof Chest){ + if(!$pair->isPaired()){ + $pair->createPair($this); + $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); @@ -210,11 +214,7 @@ class Chest extends Spawnable implements InventoryHolder, Container{ return false; } - $this->namedtag->pairx = new Int("pairx", $tile->x); - $this->namedtag->pairz = new Int("pairz", $tile->z); - - $tile->namedtag->pairx = new Int("pairx", $this->x); - $tile->namedtag->pairz = new Int("pairz", $this->z); + $this->createPair($tile); $this->spawnToAll(); $tile->spawnToAll(); @@ -223,6 +223,14 @@ class Chest extends Spawnable implements InventoryHolder, Container{ return true; } + private function createPair(Chest $tile){ + $this->namedtag->pairx = new Int("pairx", $tile->x); + $this->namedtag->pairz = new Int("pairz", $tile->z); + + $tile->namedtag->pairx = new Int("pairx", $this->x); + $tile->namedtag->pairz = new Int("pairz", $this->z); + } + public function unpair(){ if(!$this->isPaired()){ return false;