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.
This commit is contained in:
Dylan K. Taylor 2017-01-19 15:34:51 +00:00
parent 26fc21d56c
commit e4aa3d72fe

View File

@ -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;
}