Block registry api

This commit is contained in:
2026-11-12 20:41:13 -03:00
parent e7fe663746
commit 76802ed430
39 changed files with 499 additions and 100 deletions
+4 -4
View File
@@ -42,7 +42,7 @@ Deno.test("a mod's fluids/ file registers a fluid, packed into its .cubi", async
const dir = Deno.makeTempDirSync({ prefix: "bworld_fluids_" });
const syrup = { id: "testfluids:syrup", name: "Maple Syrup", color: "#a0522d", texture: "testfluids:syrup_still" };
fluid_mod(dir, { "syrup.json": syrup });
const mods = load_and_check(dir);
const mods = await load_and_check(dir);
assertEquals(mods[0].report.errors, []);
// it has no textures
assertEquals(mods[0].report.warnings, [
@@ -55,10 +55,10 @@ Deno.test("a mod's fluids/ file registers a fluid, packed into its .cubi", async
Deno.removeSync(dir, { recursive: true });
});
Deno.test("a fluid with a bad color fails loading", () => {
Deno.test("a fluid with a bad color fails loading", async () => {
const dir = Deno.makeTempDirSync({ prefix: "bworld_fluids_" });
fluid_mod(dir, { "syrup.json": { id: "testfluids:syrup", color: "brown" } });
const errors = load_and_check(dir)[0].report.errors;
const errors = (await load_and_check(dir))[0].report.errors;
assert(errors.some((e) => e.startsWith("fluids/syrup.json:") && e.includes("color")), errors.join("\n"));
Deno.removeSync(dir, { recursive: true });
});
@@ -86,7 +86,7 @@ async function both_sides(ask: (fluids: FluidApi) => unknown) {
const { game } = await test_game(dir);
const server = ask(game.mods.fluid_rules.api());
const mod = load_and_check(dir).find((m) => m.id === "testfluids")!;
const mod = (await load_and_check(dir)).find((m) => m.id === "testfluids")!;
const packed = read_mod(await pack_mod(mod), "testfluids.cubi");
Deno.removeSync(dir, { recursive: true });
const listing: ModListing = { id: "testfluids", name: "Test", version: "1.0.0", sha256: "", file: "", size: 0 };