Added Chest recreation on imported levels

This commit is contained in:
Shoghi Cervantes 2014-12-21 14:29:18 +01:00
parent 6dcb5da069
commit d7be2ce439

View File

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