Skip to content

Instantly share code, notes, and snippets.

@rom1504
Created September 5, 2015 15:14
Show Gist options
  • Save rom1504/dc8d18abc1b9734926f4 to your computer and use it in GitHub Desktop.
Save rom1504/dc8d18abc1b9734926f4 to your computer and use it in GitHub Desktop.
Sending the same chunk for 20*20 chunks
var dump=serv.world.dump();
var begin=1;
var total=20;
var x,z;
for(x=-begin;x<begin;x++)
for(z=-begin;z<begin;z++) {
player._client.write('map_chunk', {
x: x,
z: z,
groundUp: true,
bitMap: 0xffff,
chunkData: dump
});
}
var adds=[];
for(x=-total;x<total;x++)
for(z=-total;z<total;z++) {
if(x>=-begin && x<begin && z>=-begin && z<begin) continue;
(function(x,z) {
adds.push(function () {
console.log("plop " + x + " " + z);
player._client.write('map_chunk', {
x: x,
z: z,
groundUp: true,
bitMap: 0xffff,
chunkData: dump
});
});
})(x,z);
}
setTimeout(function(){
var i=0;
function next()
{
if(adds.length>i) {
setTimeout(next, 100);
adds[i]();
}
i++;
}
next();
},10000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment