registerLevel() public static method

public static registerLevel ( Level $level )
$level pocketmine\level\Level
Exemplo n.º 1
0
 public function __construct(Level $level, $weatherTime = 12000, $weatherNow = 0)
 {
     $this->level = $level;
     $this->weatherTime = $weatherTime;
     $this->weatherNow = $weatherNow;
     $this->weatherLast = 0;
     WeatherManager::registerLevel($level);
 }
Exemplo n.º 2
0
 /**
  * Init the default level data
  *
  * @param Server $server
  * @param string $name
  * @param string $path
  * @param string $provider Class that extends LevelProvider
  *
  * @throws \Throwable
  */
 public function __construct(Server $server, string $name, string $path, string $provider)
 {
     $this->blockStates = Block::$fullList;
     $this->levelId = static::$levelIdCounter++;
     $this->blockMetadata = new BlockMetadataStore($this);
     $this->server = $server;
     $this->autoSave = $server->getAutoSave();
     /** @var LevelProvider $provider */
     if (is_subclass_of($provider, LevelProvider::class, true)) {
         $this->provider = new $provider($this, $path);
     } else {
         throw new LevelException("Provider is not a subclass of LevelProvider");
     }
     $this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.level.preparing", [$this->provider->getName()]));
     $this->generator = Generator::getGenerator($this->provider->getGenerator());
     $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", 4)));
     $this->chunksPerTick = (int) $this->server->getProperty("chunk-ticking.per-tick", 40);
     $this->chunkGenerationQueueSize = (int) $this->server->getProperty("chunk-generation.queue-size", 8);
     $this->chunkPopulationQueueSize = (int) $this->server->getProperty("chunk-generation.population-queue-size", 2);
     $this->chunkTickList = [];
     $this->clearChunksOnTick = (bool) $this->server->getProperty("chunk-ticking.clear-tick-list", true);
     $this->cacheChunks = (bool) $this->server->getProperty("chunk-sending.cache-chunks", false);
     $this->timings = new LevelTimings($this);
     $this->temporalPosition = new Position(0, 0, 0, $this);
     $this->temporalVector = new Vector3(0, 0, 0);
     $this->tickRate = 1;
     $this->weather = new Weather($this, 0);
     if ($this->server->netherEnabled and $this->server->netherName == $this->folderName) {
         $this->setDimension(self::DIMENSION_NETHER);
     } else {
         $this->setDimension(self::DIMENSION_NORMAL);
     }
     if ($this->server->weatherEnabled and $this->getDimension() == self::DIMENSION_NORMAL) {
         WeatherManager::registerLevel($this);
         $this->weather->setCanCalculate(true);
     } else {
         $this->weather->setCanCalculate(false);
     }
 }