mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 12:04:46 +00:00
Re-implemented chunk sending (#304)
Re-implement chunk sending, send chunks inside a radius instead of below a count This sends chunks in concentric squares around players. When the radius is hit, it will pad out the radius until a full circle of chunks is loaded around the player. TODO: implement radius-per-tick, send chunks in concentric circles, use radius for player spawning. To set your server chunk radius, change `view-distance` in server.properties. Values are intended to be the same as MCPE render distance values. With matching client and server render distances the chunks should reach the horizon. NOTE: You may notice significantly increased memory usage per player when increasing these values to something respectable. This is normal and expected. A player with render distance 14 for example will cause loading of 600+ chunks. A player cannot however exceed the render distance limit set in server.properties - the server will simply not send any more chunks. Render distance of 8 chunks is approximately 200 chunks. This is roughly equivalent to the original default max-chunks of 192 in pocketmine.yml, but sent in a circle instead of a square. Wait for client to request a chunk radius before ordering chunks Use 8 for default maximum radius (roughly matches old setting of 192) Calculate spawn chunk count from chunk-sending.spawn-radius
This commit is contained in:
@@ -333,8 +333,19 @@ class Server{
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getViewDistance(){
|
||||
return max(56, $this->getProperty("chunk-sending.max-chunks", 256));
|
||||
public function getViewDistance() : int{
|
||||
return max(2, $this->getConfigInt("view-distance", 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view distance up to the currently-allowed limit.
|
||||
*
|
||||
* @param int $distance
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAllowedViewDistance(int $distance) : int{
|
||||
return max(2, min($distance, $this->memoryManager->getViewDistance($this->getViewDistance())));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1384,6 +1395,7 @@ class Server{
|
||||
"enable-rcon" => false,
|
||||
"rcon.password" => substr(base64_encode(random_bytes(20)), 3, 10),
|
||||
"auto-save" => true,
|
||||
"view-distance" => 8
|
||||
]);
|
||||
|
||||
$this->forceLanguage = $this->getProperty("settings.force-language", false);
|
||||
|
Reference in New Issue
Block a user