getProvider() === null){ throw new \Exception("Invalid garbage Chunk given to Tile"); } $this->timings = Timings::getTileEntityTimings($this); $this->server = $chunk->getProvider()->getLevel()->getServer(); $this->chunk = $chunk; $this->setLevel($chunk->getProvider()->getLevel()); $this->namedtag = $nbt; $this->closed = false; $this->name = ""; $this->lastUpdate = microtime(true); $this->id = Tile::$tileCount++; $this->x = (int) $this->namedtag["x"]; $this->y = (int) $this->namedtag["y"]; $this->z = (int) $this->namedtag["z"]; $this->chunk->addTile($this); $this->getLevel()->addTile($this); $this->tickTimer = Timings::getTileEntityTimings($this); } public function getID(){ return $this->id; } public function saveNBT(){ $this->namedtag->x = new Int("x", $this->x); $this->namedtag->y = new Int("y", $this->y); $this->namedtag->z = new Int("z", $this->z); } /** * @return \pocketmine\block\Block */ public function getBlock(){ return $this->level->getBlock($this); } public function onUpdate(){ return false; } public final function scheduleUpdate(){ $this->level->updateTiles[$this->id] = $this; } public function __destruct(){ $this->close(); } public function close(){ if($this->closed === false){ $this->closed = true; unset($this->level->updateTiles[$this->id]); if($this->chunk instanceof FullChunk){ $this->chunk->removeTile($this); } if(($level = $this->getLevel()) instanceof Level){ $level->removeTile($this); } $this->level = null; } } public function getName(){ return $this->name; } }