Created
August 15, 2020 16:49
-
-
Save PJZ9n/91992f1639bd58aab530990885771084 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function onPlayerJoin(PlayerJoinEvent $event): void | |
{ | |
$player = $event->getPlayer(); | |
$level = $this->getServer()->getDefaultLevel(); | |
$chunkZ = 0; | |
$createCount = 0; | |
$failedCount = 0; | |
$this->getScheduler()->scheduleDelayedRepeatingTask(new ClosureTask(function (int $currentTick) use ($level, $player, &$chunkZ, &$createCount, &$failedCount) : void { | |
for ($i = 0; $i < 10; $i++) { | |
for ($j = 0; $j < 10; $j++) { | |
//$level->loadChunk($j, $chunkZ + $i) ? $createCount++ : $failedCount++; | |
$level->requestChunk($j, $chunkZ + $i, $player); | |
} | |
} | |
$createCount += 100; | |
$chunkZ += 100; | |
}), 200, 200); | |
$this->getScheduler()->scheduleRepeatingTask(new ClosureTask(function (int $currentTick) use (&$createCount, &$failedCount, &$chunkZ) : void { | |
$this->getLogger()->info("-----STATUS-----"); | |
$this->getLogger()->info("Create Count: " . $createCount); | |
$this->getLogger()->info("Failed Count: " . $failedCount); | |
$this->getLogger()->info("ChunkX: n, ChunkZ: " . $chunkZ); | |
}), 20 * 10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment