Move world generation outside the engine and into mods and data files

This commit is contained in:
2026-10-11 00:33:59 -03:00
parent afe6e03d4c
commit 3d2b235f64
118 changed files with 8250 additions and 1108 deletions
+7 -5
View File
@@ -128,7 +128,7 @@ Deno.test("the template's worldgen feature places boulders, the same way every t
const { game } = await test_game(dir, undefined, "boulder-seed");
const worldgen = game.world.worldgen!;
// after the base game's, in load order
assertEquals(worldgen.features.map((f) => f.id), ["bworld:cactus", "copper_tools:boulders"]);
assertEquals(worldgen.features.map((f) => f.id), ["bworld:trees", "bworld:cactus", "copper_tools:boulders"]);
// compare against generation without the template: boulders are extra stone on top of the surface
const without = { ...worldgen, features: worldgen.features.filter((f) => f.id !== "copper_tools:boulders") };
@@ -143,13 +143,15 @@ Deno.test("the template's worldgen feature places boulders, the same way every t
assert(boulders >= 1 && boulders <= 8, `${boulders} of 20 chunks got a boulder, expected about 2`);
// loading the script again (like a client does) gives the same terrain
const again = await load_worldgen(
["bworld", "copper_tools"].map((mod) => ({
const again = await load_worldgen({
mods: ["bworld", "copper_tools"],
scripts: ["bworld", "copper_tools"].map((mod) => ({
mod,
url: new URL(`file://${Deno.realPathSync(dir)}/${mod}/scripts/worldgen.ts`).href,
})),
[],
);
ores: worldgen.ores,
generator: "bworld:overworld",
});
for (let cx = 0; cx < 20; cx++) {
assertEquals(
generate_raw_chunk(cx, 0, "boulder-seed", game.world.block_ids, again).blocks,