add a server setting view-distance, and take the min of that settings and the player settings to get the distance to send chunks

I experimented with vanilla, and its "MultiplayerChunkCache" indicates this behavior for a vanilla server
progress on #127
This commit is contained in:
Romain Beaumont 2015-11-26 01:32:35 +01:00
parent fb5450e3ca
commit 7f47dacc60
2 changed files with 4 additions and 3 deletions

View file

@ -15,5 +15,6 @@
"plugins": {
},
"modpe": false
"modpe": false,
"view-distance":10
}

View file

@ -51,7 +51,7 @@ module.exports.server=function(serv,{regionFolder,generation={"name":"diamond_sq
//serv.pregenWorld(serv.netherworld).then(() => serv.log('Pre-Generated Nether'));
};
module.exports.player=function(player,serv) {
module.exports.player=function(player,serv,settings) {
player.spawnEntity = entity => {
player._client.write(entity.spawnPacketName, entity.getSpawnPacket());
@ -151,7 +151,7 @@ module.exports.player=function(player,serv) {
player.sendRestMap = () =>
{
player.sendingChunks=true;
player.sendNearbyChunks(player.view,true)
player.sendNearbyChunks(Math.min(player.view,settings["view-distance"]),true)
.then(() => player.sendingChunks=false)
.catch((err)=> setTimeout(() => {throw err;},0));
};