getProvider() === null){ throw new \Exception("Invalid garbage Chunk given to Tile"); } $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"] = $this->x; $this->namedtag["y"] = $this->y; $this->namedtag["z"] = $this->z; } public function onUpdate(){ return false; } public final function scheduleUpdate(){ //TODO! Tile::$needUpdate[$this->id] = $this; } public function __destruct(){ $this->close(); } public function close(){ if($this->closed === false){ $this->closed = true; unset(Tile::$needUpdate[$this->id]); if($this->chunk instanceof FullChunk){ $this->chunk->removeTile($this); } if(($level = $this->getLevel()) instanceof Level){ $level->removeTile($this); } } } public function getName(){ return $this->name; } }