chunk result
Some checks failed
docker / build (push) Has been cancelled
jshint / build (push) Has been cancelled
test / build (push) Has been cancelled

This commit is contained in:
BuckarooBanzay 2020-10-16 12:56:48 +02:00
parent a59e7e86e1
commit f0a8543b37

View File

@ -2,11 +2,18 @@ const checkchunk = require("./checkchunk");
module.exports = function(pos){
const promises = [];
let centralchunkindex;
for (var x=pos.x-1; x<=pos.x+1; x++){
for (var y=pos.y-1; y<=pos.y+1; y++){
for (var z=pos.z-1; z<=pos.z+1; z++){
const coord = { x:x, y:y, z:z };
promises.push(checkchunk(coord));
if (x == pos.x && y == pos.y && z == pos.z){
// central chunk, remember for later
centralchunkindex = promises.length - 1;
}
}
}
}
@ -14,8 +21,10 @@ module.exports = function(pos){
return Promise.all(promises)
.then(results => {
return {
// mark as protected if *any* surrounding chunk is protected
protected: results.some(res => res.protected),
generated: results.some(res => res.generated)
// return generated property of central chunk
generated: results[centralchunkindex].generated
};
});
};