Single module modding

This commit is contained in:
2026-11-14 12:18:41 -03:00
parent 605008f584
commit 313098892e
134 changed files with 919 additions and 924 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ import { copy_dir, test_game } from "./helpers.ts";
const SCRIPT = `
import type { WorldgenContext } from "cubi/worldgen";
export function setup(gen: WorldgenContext) {
export function worldgen(gen: WorldgenContext) {
// a type for data features: a pillar of a block
gen.register_feature_type<{ block: string; height: number }>("testmod:pillar", (chunk, config, origin) => {
for (let i = 0; i < config.height; i++) chunk.set_block(origin.x, origin.y + i, origin.z, config.block);
@@ -50,7 +50,7 @@ function with_mod(files: Record<string, unknown>, script = SCRIPT) {
name: "Test",
version: "1.0.0",
dependencies: [{ id: "bworld", version: "*" }],
scripts: { worldgen: "scripts/worldgen.ts" },
main: "scripts/worldgen.ts",
}),
);
write("scripts/worldgen.ts", script);
@@ -135,7 +135,7 @@ Deno.test("a data feature whose type no script registers stops the server", asyn
await assertRejects(
() => test_game(dir),
Error,
"type testmod:nothing isn't built in, and no worldgen script registered it",
"type testmod:nothing isn't built in, and no mod's worldgen phase registered it",
);
} finally {
Deno.removeSync(dir, { recursive: true });
@@ -146,7 +146,7 @@ Deno.test("a feature can't be both code and data", async () => {
const clash = with_mod(
{ "worldgen/features/glass_pillar.json": GLASS_PILLAR },
`import type { WorldgenContext } from "cubi/worldgen";
export function setup(gen: WorldgenContext) {
export function worldgen(gen: WorldgenContext) {
gen.register_feature("testmod:glass_pillar", () => {});
}`,
);