From e4aa3d72fef8651f728ab83a030356ffdfe09a5d Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Thu, 19 Jan 2017 15:34:51 +0000 Subject: [PATCH] Check for unloaded chunks, fix triple chest bug, fix Chest object leak, close #256 Revert "Fixed double chest tile memory leak on shutdown, close #256 (#261)" This reverts commit 9869aaa46ae38443ad860e9f4e5bb240d80536c7. --- src/pocketmine/tile/Chest.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index 52cca2785..b055ad899 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -40,9 +40,6 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ /** @var DoubleChestInventory */ protected $doubleInventory = null; - /** @var bool */ - private $hasClosedPair = false; - public function __construct(Chunk $chunk, CompoundTag $nbt){ parent::__construct($chunk, $nbt); $this->inventory = new ChestInventory($this); @@ -59,10 +56,6 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ public function close(){ if($this->closed === false){ - if($this->isPaired()){ - $this->getPair()->hasClosedPair = true; - } - foreach($this->getInventory()->getViewers() as $player){ $player->removeWindow($this->getInventory()); } @@ -169,7 +162,11 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ } protected function checkPairing(){ - if(($pair = $this->getPair()) instanceof Chest){ + if($this->isPaired() and !$this->getLevel()->isChunkLoaded($this->namedtag->pairx->getValue() >> 4, $this->namedtag->pairz->getValue() >> 4)){ + //paired to a tile in an unloaded chunk + $this->doubleInventory = null; + + }elseif(($pair = $this->getPair()) instanceof Chest){ if(!$pair->isPaired()){ $pair->createPair($this); $pair->checkPairing(); @@ -205,7 +202,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ } public function isPaired(){ - if(!isset($this->namedtag->pairx) or !isset($this->namedtag->pairz) or $this->hasClosedPair){ + if(!isset($this->namedtag->pairx) or !isset($this->namedtag->pairz)){ return false; }