Added "view-distance" setting to change chunk sending radius

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-09 17:07:17 +02:00
parent e88c337229
commit dccfbfd572
2 changed files with 8 additions and 3 deletions

View File

@ -96,6 +96,7 @@ class ServerAPI{
"white-list" => false,
"debug" => 1,
"spawn-protection" => 16,
"view-distance" => 7,
"max-players" => 20,
"server-type" => "normal",
"time-per-second" => 20,

View File

@ -107,10 +107,10 @@ class Player{
asort($this->chunksOrder);
}
public function getNextChunk(){
public function getNextChunk($repeat = false){
$c = key($this->chunksOrder);
$d = $this->chunksOrder[$c];
if($c === null or $d > 6){
if($c === null or $d > $this->server->getProperty("view-distance")){
$this->server->schedule(50, array($this, "getNextChunk"));
return false;
}
@ -139,7 +139,11 @@ class Player{
$this->server->api->tileentity->spawnTo($tile["ID"], $this);
}
}
$this->server->schedule(0.5, array($this, "getNextChunk"));
if($repeat === false){
$this->getNextChunk(true);
}
$this->server->schedule(1, array($this, "getNextChunk"));
}
public function onTick($time, $event){