Added chunk spawn threshold for players

This commit is contained in:
Shoghi Cervantes 2015-03-26 11:28:44 +01:00
parent ed2ba70a29
commit 286c1ee880
2 changed files with 5 additions and 12 deletions

View File

@ -191,6 +191,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
protected $viewDistance; protected $viewDistance;
protected $chunksPerTick; protected $chunksPerTick;
protected $spawnThreshold;
/** @var null|Position */ /** @var null|Position */
private $spawnPosition = null; private $spawnPosition = null;
@ -429,6 +430,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->port = $port; $this->port = $port;
$this->clientID = $clientID; $this->clientID = $clientID;
$this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4); $this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4);
$this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56);
$this->spawnPosition = null; $this->spawnPosition = null;
$this->gamemode = $this->server->getGamemode(); $this->gamemode = $this->server->getGamemode();
$this->setLevel($this->server->getDefaultLevel(), true); $this->setLevel($this->server->getDefaultLevel(), true);
@ -610,18 +612,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$this->level->requestChunk($X, $Z, $this, LevelProvider::ORDER_ZXY); $this->level->requestChunk($X, $Z, $this, LevelProvider::ORDER_ZXY);
} }
if(count($this->usedChunks) >= 8 and $this->spawned === false){ if(count($this->usedChunks) >= $this->spawnThreshold and $this->spawned === false){
$spawned = 0;
foreach($this->usedChunks as $d){
if($d === true){
$spawned++;
}
}
if($spawned < 4){
return;
}
$this->spawned = true; $this->spawned = true;
$this->sendSettings(); $this->sendSettings();

View File

@ -46,6 +46,8 @@ chunk-sending:
per-tick: 8 per-tick: 8
#Amount of chunks sent around each player #Amount of chunks sent around each player
max-chunks: 256 max-chunks: 256
#Amount of chunks that need to be sent before spawning the player
spawn-threshold: 56
chunk-ticking: chunk-ticking:
#Max amount of chunks processed each tick #Max amount of chunks processed each tick