Single module modding
This commit is contained in:
@@ -1,14 +1,13 @@
|
||||
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
// imports mods' worldgen scripts and collects what they and mods' data add to generation: the generator, ores, and
|
||||
// runs mods' worldgen phases and collects what they and mods' data add to generation: the generator, ores, and
|
||||
// features, code and data, in the order they run. used by the game server
|
||||
import type { FeatureChunk, FeatureStep, WorldgenContext } from "@/common/mod_api/worldgen.ts";
|
||||
import type { OreJson } from "@/common/mod_data.ts";
|
||||
import type { SetupFeature, WorldgenSetup } from "./generation.ts";
|
||||
import { EverythingRegistry } from "./everything_registry.ts";
|
||||
import { ModLoadError } from "./mod_loader.ts";
|
||||
import { loading_mod } from "./hooks.ts";
|
||||
import { ModLoadError, run_phase } from "./mod_loader.ts";
|
||||
import { compile_generator } from "./worldgen/generator.ts";
|
||||
import type { WorldShape } from "./world_shape.ts";
|
||||
import {
|
||||
@@ -97,13 +96,7 @@ export async function load_worldgen(sources: WorldgenSources): Promise<WorldgenS
|
||||
},
|
||||
};
|
||||
|
||||
await loading_mod(mod, engine_access ?? false, async () => {
|
||||
const module = await import(url);
|
||||
if (typeof module.setup !== "function") {
|
||||
throw new ModLoadError(mod, "the worldgen script doesn't export a setup function");
|
||||
}
|
||||
await module.setup(ctx);
|
||||
});
|
||||
await run_phase({ id: mod, engine_access }, url, "worldgen", () => ctx);
|
||||
}
|
||||
|
||||
// data features last, so they can use the types and modifiers every script registered
|
||||
|
||||
Reference in New Issue
Block a user