namedtag->pairx) or !isset($this->namedtag->pairz)){ return false; } return true; } public function getPair(){ if($this->isPaired()){ return $this->getLevel()->getTile(new Vector3((int) $this->namedtag->pairx, $this->y, (int) $this->namedtag->pairz)); } return false; } public function pairWith(Chest $tile){ if($this->isPaired() or $tile->isPaired()){ return false; } $this->namedtag->pairx = $tile->x; $this->namedtag->pairz = $tile->z; $tile->namedtag->pairx = $this->x; $tile->namedtag->pairz = $this->z; $this->spawnToAll(); $tile->spawnToAll(); //TODO: Update to new events $this->server->handle("tile.update", $this); $this->server->handle("tile.update", $tile); return true; } public function unpair(){ if(!$this->isPaired()){ return false; } $tile = $this->getPair(); unset($this->namedtag->pairx, $this->namedtag->pairz, $tile->namedtag->pairx, $tile->namedtag->pairz); $this->spawnToAll(); $this->server->handle("tile.update", $this); if($tile instanceof Chest){ $tile->spawnToAll(); $this->server->handle("tile.update", $tile); } return true; } public function spawnTo(Player $player){ if($this->closed){ return false; } $nbt = new NBT(NBT::LITTLE_ENDIAN); if($this->isPaired()){ $nbt->setData(new Compound("", array( new String("id", Tile::CHEST), new Int("x", (int) $this->x), new Int("y", (int) $this->y), new Int("z", (int) $this->z), new Int("pairx", (int) $this->namedtag->pairx), new Int("pairz", (int) $this->namedtag->pairz) ))); }else{ $nbt->setData(new Compound("", array( new String("id", Tile::CHEST), new Int("x", (int) $this->x), new Int("y", (int) $this->y), new Int("z", (int) $this->z) ))); } $pk = new EntityDataPacket; $pk->x = $this->x; $pk->y = $this->y; $pk->z = $this->z; $pk->namedtag = $nbt->write(); $player->dataPacket($pk); return true; } }