mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-19 14:31:17 +00:00
31 lines
No EOL
957 B
JavaScript
31 lines
No EOL
957 B
JavaScript
var Chunk = require('prismarine-chunk')(require("../version"));
|
|
var Vec3 = require('vec3');
|
|
|
|
function generation({level=50}={}) {
|
|
function generateChunk(chunkX, chunkZ) {
|
|
var chunk=new Chunk();
|
|
for (var x = 0; x < 16; x++) {
|
|
for (var z = 0; z < 16; z++) {
|
|
var bedrockheighttop = 1 + Math.round(Math.random()*3)
|
|
var bedrockheightbottom = 1 + Math.round(Math.random()*3)
|
|
for (var y = 0; y < 128; y++) { // Nether only goes up to 128
|
|
let block;
|
|
let data;
|
|
|
|
if (y < bedrockheightbottom) block = 7;
|
|
else if (y < 50) block = 87;
|
|
else if (y > 127 - bedrockheighttop) block = 7;
|
|
|
|
var pos = new Vec3(x, y, z);
|
|
if (block) chunk.setBlockType(pos, block);
|
|
if (data) chunk.setBlockData(pos, data);
|
|
// Don't need to set light data in nether
|
|
}
|
|
}
|
|
}
|
|
return chunk;
|
|
}
|
|
return generateChunk;
|
|
}
|
|
|
|
module.exports = generation; |