id; } public function __construct(Level $level, Compound $nbt){ $this->server = Server::getInstance(); $this->setLevel($level, true); //Strong reference $this->namedtag = $nbt; $this->closed = false; $this->name = ""; $this->lastUpdate = microtime(true); $this->id = Tile::$tileCount++; Tile::$list[$this->id] = $this; $this->x = (int) $this->namedtag["x"]; $this->y = (int) $this->namedtag["y"]; $this->z = (int) $this->namedtag["z"]; $index = LevelFormat::getIndex($this->x >> 4, $this->z >> 4); $this->chunkIndex = $index; $this->getLevel()->tiles[$this->id] = $this; $this->getLevel()->chunkTiles[$this->chunkIndex][$this->id] = $this; } public function onUpdate(){ return false; } public final function scheduleUpdate(){ Tile::$needUpdate[$this->id] = $this; } public function close(){ if($this->closed === false){ $this->closed = true; unset(Tile::$needUpdate[$this->id]); unset($this->getLevel()->tiles[$this->id]); unset($this->getLevel()->chunkTiles[$this->chunkIndex][$this->id]); unset(Tile::$list[$this->id]); } } public function __destruct(){ $this->close(); } public function getName(){ return $this->name; } }