From dccfbfd5724aa5108acb8596d571405b4c163b8e Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Tue, 9 Apr 2013 17:07:17 +0200 Subject: [PATCH] Added "view-distance" setting to change chunk sending radius --- src/API/ServerAPI.php | 1 + src/Player.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/API/ServerAPI.php b/src/API/ServerAPI.php index 52a65cdbb..95be42725 100644 --- a/src/API/ServerAPI.php +++ b/src/API/ServerAPI.php @@ -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, diff --git a/src/Player.php b/src/Player.php index 1af34d701..e5a6eaf41 100644 --- a/src/Player.php +++ b/src/Player.php @@ -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){