/** * Init the default level data * * @param Server $server * @param string $name * @param string $path * @param string $provider Class that extends LevelProvider * * @throws \Exception */ public function __construct(Server $server, $name, $path, $provider) { $this->levelId = static::$levelIdCounter++; $this->blockMetadata = new BlockMetadataStore($this); $this->server = $server; /** @var LevelProvider $provider */ if (is_subclass_of($provider, "pocketmine\\level\\format\\LevelProvider", true)) { $this->provider = new $provider($this, $path); } else { throw new \Exception("Provider is not a subclass of LevelProvider"); } $this->server->getLogger()->info("Preparing level \"" . $this->provider->getName() . "\""); $generator = Generator::getGenerator($this->provider->getGenerator()); $this->server->getGenerationManager()->openLevel($this, $generator, $this->provider->getGeneratorOptions()); $this->blockOrder = $provider::getProviderOrder(); $this->useSections = $provider::usesChunkSection(); $this->folderName = $name; $this->updateQueue = new ReversePriorityQueue(); $this->updateQueue->setExtractFlags(\SplPriorityQueue::EXTR_BOTH); $this->time = (int) $this->provider->getTime(); $this->chunkTickRadius = min($this->server->getViewDistance(), max(1, (int) $this->server->getProperty("chunk-ticking.tick-radius", 3))); $this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 80); $this->chunkTickList = []; $this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", false); $this->timings = new LevelTimings($this); }
public function initLevel() { $generator = $this->generator; $this->generatorInstance = new $generator($this->provider->getGeneratorOptions()); $this->generatorInstance->init($this, new Random($this->getSeed())); $this->registerGenerator(); }
public function initLevel() { $this->server->getGenerationManager()->openLevel($this, $this->generator, $this->provider->getGeneratorOptions()); }