mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-16 21:11:22 +00:00
Added waterline + dirt/bedrock height
This commit is contained in:
parent
fd6e2f97ab
commit
c72452da79
1 changed files with 18 additions and 7 deletions
|
|
@ -107,18 +107,29 @@ function generation({seed,worldHeight=80,waterline=20}={}) {
|
|||
for (var x = 0; x < 16; x++) {
|
||||
for (var z = 0; z < 16; z++) {
|
||||
var level = Math.floor(space.value(worldX + x, worldZ + z) * worldHeight);
|
||||
var dirtheight = level - 4 + Math.round(Math.random()*2);
|
||||
var bedrockheight = 1 + Math.round(Math.random()*3)
|
||||
for (var y = 0; y < 256; y++) {
|
||||
let block;
|
||||
let data;
|
||||
|
||||
if (y == 0) block = 7;
|
||||
else if (y < level) block = 3;
|
||||
else if (y == level && y < waterline) block = 3;
|
||||
else if (y == level) block = 2;
|
||||
else if (y < waterline) block = 9;
|
||||
var surfaceblock = level < waterline ? 12 : 2; // Sand below water, grass
|
||||
var belowblock = level < waterline ? 12 : 3; // 3-5 blocks below surface
|
||||
|
||||
if (block) chunk.setBlockType(new Vec3(x, y, z), block);
|
||||
if (y < bedrockheight) block = 7; // Solid bedrock at bottom
|
||||
else if (y < level && y >= dirtheight) block = belowblock; // Dirt/sand below surface
|
||||
else if (y < level) block = 1; // Set stone inbetween
|
||||
else if (y == level) block = surfaceblock; // Set surface sand/grass
|
||||
else if (y <= waterline) block = 9; // Set the water
|
||||
else if (y == level+1 && level >= waterline && Math.random() < 0.1) { // 1/10 chance of grass
|
||||
block = 31;
|
||||
data = 1;
|
||||
}
|
||||
|
||||
chunk.setSkyLight(new Vec3(x, y, z), 15);
|
||||
var pos = new Vec3(x, y, z);
|
||||
if (block) chunk.setBlockType(pos, block);
|
||||
if (data) chunk.setBlockData(pos, data);
|
||||
chunk.setSkyLight(pos, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue