World sections

This commit is contained in:
2026-11-06 23:13:34 -03:00
parent 818ce22dd6
commit 1fa47c027d
21 changed files with 392 additions and 127 deletions
+7 -6
View File
@@ -4,7 +4,6 @@
// the terrain is data: noises, density functions, noise settings and biome sources in mods' worldgen folders, see
// docs/modding/worldgen/terrain.md. tests/worldgen_golden_test.ts checks the base game's makes the same world
import { assert, assertEquals, assertRejects } from "@std/assert";
import { CHUNK_AREA } from "@/common/constants.ts";
import { generate_raw_chunk } from "@/common/generation.ts";
import { copy_dir, test_game } from "./helpers.ts";
@@ -54,14 +53,16 @@ Deno.test("a mod's biome generates where its rule, added to the base game's, say
let fields = 0;
for (let cx = -2; cx < 2; cx++) {
for (let cz = -2; cz < 2; cz++) {
const { blocks, biomes } = generate_raw_chunk(cx, cz, "lavender", block_ids, worldgen, default_values);
biomes.forEach((biome, column) => {
const { column } = generate_raw_chunk(cx, cz, "lavender", block_ids, worldgen, default_values);
const { min_y, max_y } = game.world.shape;
column.biomes.forEach((biome, i) => {
if (biome !== "lavender:fields") return;
fields++;
// its surface: the top block of the column is its sand
let y = game.world.shape.height - 1;
while (y > 0 && blocks[y * CHUNK_AREA + column] === 0) y--;
assertEquals(blocks[y * CHUNK_AREA + column], block_ids["bworld:sand"]);
const [x, z] = [cx * 16 + i % 16, cz * 16 + Math.floor(i / 16)];
let y = max_y - 1;
while (y > min_y && column.get(x, y, z) === 0) y--;
assertEquals(column.get(x, y, z), block_ids["bworld:sand"]);
});
}
}