mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 04:38:35 +00:00
Order chunks to be generated
This commit is contained in:
parent
d616e73242
commit
e462a89189
@ -1069,10 +1069,35 @@ class Server{
|
|||||||
|
|
||||||
$this->getLogger()->notice("Spawn terrain for level \"$name\" is being generated in the background");
|
$this->getLogger()->notice("Spawn terrain for level \"$name\" is being generated in the background");
|
||||||
|
|
||||||
for($Z = 0; $Z <= 16; ++$Z){
|
|
||||||
for($X = 0; $X <= 16; ++$X){
|
$radiusSquared = ($this->getViewDistance() + 1) / M_PI;
|
||||||
$level->generateChunk($X, $Z);
|
$radius = ceil(sqrt($radiusSquared));
|
||||||
|
|
||||||
|
$centerX = $level->getSpawn()->getX() >> 4;
|
||||||
|
$centerZ = $level->getSpawn()->getZ() >> 4;
|
||||||
|
|
||||||
|
$order = [];
|
||||||
|
|
||||||
|
for($X = -$radius; $X <= $radius; ++$X){
|
||||||
|
for($Z = -$radius; $Z <= $radius; ++$Z){
|
||||||
|
$distance = ($X * $X) + ($Z * $Z);
|
||||||
|
if($distance > $radiusSquared){
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
$chunkX = $X + $centerX;
|
||||||
|
$chunkZ = $Z + $centerZ;
|
||||||
|
$index = Level::chunkHash($chunkX, $chunkZ);
|
||||||
|
$order[$index] = $distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
asort($order);
|
||||||
|
|
||||||
|
$chunkX = $chunkZ = null;
|
||||||
|
|
||||||
|
foreach($order as $index => $distance){
|
||||||
|
Level::getXZ($index, $chunkX, $chunkZ);
|
||||||
|
$level->generateChunk($chunkX, $chunkZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user