From afacd10a1842d3ca98ff2a0c771b61c45fd8907f Mon Sep 17 00:00:00 2001 From: Paula Date: Sun, 15 Nov 2026 09:53:31 -0300 Subject: [PATCH] Actually fix default dimensions with multiple mods --- common/mod_check.ts | 10 ++-------- docs/modding/worldgen/terrain.md | 7 +++++-- mods/dangerous_business/worldgen/dimension/void.json | 2 +- server/main.ts | 4 ++++ tests/helpers.ts | 5 ++++- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/common/mod_check.ts b/common/mod_check.ts index 660c87b..6c95749 100644 --- a/common/mod_check.ts +++ b/common/mod_check.ts @@ -186,8 +186,6 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable(); const all_noise_settings: NoiseSettingsJson[] = []; const feature_owners = new Map(); @@ -225,7 +223,6 @@ export function check_references(mods: LoadedMod[], engine_textures: Iterable 1) { - errors.push( - `${file}: only one dimension can be the default, and these all are: ${defaults.join(", ")}`, - ); - } + // whether exactly one is the default is up to the server, with the mods a world plays: a folder of mods + // can hold several games, each with its own } for (const { file, json } of mod.biome_sources ?? []) { const refs = new_refs(); diff --git a/docs/modding/worldgen/terrain.md b/docs/modding/worldgen/terrain.md index 598cf03..6052ffa 100644 --- a/docs/modding/worldgen/terrain.md +++ b/docs/modding/worldgen/terrain.md @@ -335,8 +335,11 @@ torches, light it, and day and night don't change how bright it is. The sky is s The world plays the dimension with `"default": true`. Exactly one dimension in the loaded mods can be the default: with none, or more than one, the server doesn't start, and the error names them. A mod can have dimensions that aren't the -default, but nothing plays them yet. Since a mod can't change another mod's files yet, a mod with a default dimension of -its own, like a flat world, can't be loaded with the base game's for now. +default, but nothing plays them yet. + +A mod with a default dimension of its own, like a flat world or a game that doesn't build on the base game, is played +without the base game: a singleplayer world picks its mods, and a dedicated server loads the ones `MODS` names, like +`MODS=my_game,recipe_viewer`. `check-mods` doesn't mind a folder holding several, since each world plays one. There's one dimension per world for now, there's no travelling between them yet. diff --git a/mods/dangerous_business/worldgen/dimension/void.json b/mods/dangerous_business/worldgen/dimension/void.json index 006c4b8..42554f9 100644 --- a/mods/dangerous_business/worldgen/dimension/void.json +++ b/mods/dangerous_business/worldgen/dimension/void.json @@ -3,6 +3,6 @@ "dimension": { "id": "dangerous_business:void", "generator": "dangerous_business:void", - "default": false + "default": true } } diff --git a/server/main.ts b/server/main.ts index 3731f35..742b059 100644 --- a/server/main.ts +++ b/server/main.ts @@ -2,6 +2,7 @@ // SPDX-License-Identifier: AGPL-3.0-or-later // a dedicated server: the host from server/host.ts on a port, saving the world when it's stopped +import { MOD_EXTENSION } from "@/common/mod.ts"; import { type Host, start_host } from "./host.ts"; const PORT = Number(Deno.env.get("PORT") ?? 8000); @@ -11,6 +12,9 @@ try { host = await start_host({ build_dir: Deno.env.get("BUILD_DIR") ?? "build", server_mods_dir: Deno.env.get("SERVER_MODS_DIR") ?? "server_mods", + // which mods to play, by id, like MODS=bworld,create. each is .cubi, as deno task build names them. every + // one when left out, which only works while server_mods/ has a single game with a default dimension + mod_files: Deno.env.get("MODS")?.split(",").map((id) => `${id.trim()}${MOD_EXTENSION}`), config_dir: Deno.env.get("CONFIG_DIR") ?? "config", dist_dir: Deno.env.get("DIST_DIR") ?? "dist", world_dir: Deno.env.get("WORLD_DIR") ?? "world", diff --git a/tests/helpers.ts b/tests/helpers.ts index 24e2bfd..f20628f 100644 --- a/tests/helpers.ts +++ b/tests/helpers.ts @@ -42,7 +42,10 @@ let repo_mods: ServerModSource[] | undefined; // own copy, so a test that changes what it got can't change another test's export async function mod_sources(mods_dir: string): Promise { if (resolve(mods_dir) !== resolve("mods")) return await read_mod_sources(mods_dir); - repo_mods ??= await read_mod_sources(mods_dir); + // other games in mods/, the ones with a default dimension of their own, are left out: tests play bworld + repo_mods ??= (await read_mod_sources(mods_dir)).filter((mod) => + mod.listing.id === "bworld" || !mod.data.dimensions?.some((json) => json.default) + ); return structuredClone(repo_mods); }