World shape for dimension

This commit is contained in:
2026-11-06 22:49:43 -03:00
parent 7458a2d42a
commit 818ce22dd6
60 changed files with 749 additions and 349 deletions
+10 -2
View File
@@ -6,7 +6,8 @@
import { register_mod_data } from "@/common/mod_loader.ts";
import type { ModData, ModListing } from "@/common/mod_loader.ts";
import { load_worldgen } from "@/common/worldgen_loader.ts";
import type { DimensionJson } from "@/common/worldgen/data.ts";
import { dimension_shape, type DimensionJson } from "@/common/worldgen/data.ts";
import { cell_height_problem } from "@/common/world_shape.ts";
import { worldgen_bundle } from "@/common/worldgen_bundle.ts";
import { GameHost, GameServer } from "./game_server.ts";
import type { WorldSource } from "./saves.ts";
@@ -42,7 +43,9 @@ export async function start_game(
for (const json of mod.data.entities) register_entity_type(json.id, mod_entity_factory(json));
}
const generator = default_dimension(mods).generator;
const dimension = default_dimension(mods);
const generator = dimension.generator;
const shape = dimension_shape(dimension);
const worldgen_scripts = mods.flatMap((mod) =>
mod.worldgen_url
? [{ mod: mod.listing.id, url: mod.worldgen_url, engine_access: mod.listing.engine_access }]
@@ -53,7 +56,11 @@ export async function start_game(
scripts: worldgen_scripts,
ores: recipes.ores,
generator,
shape,
});
const { terrain, caves } = worldgen.generator.settings;
const problem = cell_height_problem(shape, [terrain.cell_height, caves.cell_height]);
if (problem) throw new Error(`dimension ${dimension.id} can't be generated by ${generator}: ${problem}`);
const runtime = new ModRuntime();
// before the world loads, its mobs can have effects
@@ -80,6 +87,7 @@ export async function start_game(
game.worldgen_bundle = worldgen_bundle(
game.world.seed,
generator,
shape,
mods.map((mod) => ({
id: mod.listing.id,
data: mod.data,