Block registry api
This commit is contained in:
@@ -205,19 +205,19 @@ Deno.test("in a dimension without sky light only blocks give light", async () =>
|
||||
});
|
||||
|
||||
Deno.test("a dimension's min_y and max_y have to be whole sections, and fit its generator's cells", async () => {
|
||||
const errors = (options: Parameters<typeof mods>[0]) => {
|
||||
const errors = async (options: Parameters<typeof mods>[0]) => {
|
||||
const dir = mods(options);
|
||||
const report = load_and_check(dir).find((mod) => mod.id === "flat")!.report;
|
||||
const report = (await load_and_check(dir)).find((mod) => mod.id === "flat")!.report;
|
||||
Deno.removeSync(dir, { recursive: true });
|
||||
return report.errors.filter((error) => error.includes("worldgen/dimension/flat.json"));
|
||||
};
|
||||
assertEquals(errors({ flat: true, bworld_default: false, shape: TALL }), []);
|
||||
assertEquals(await errors({ flat: true, bworld_default: false, shape: TALL }), []);
|
||||
for (const shape of [{ min_y: -8 }, { max_y: 0 }, { min_y: -4096 }, { max_y: 4096 }]) {
|
||||
assertEquals(errors({ flat: true, bworld_default: false, shape }).length, 1, JSON.stringify(shape));
|
||||
assertEquals((await errors({ flat: true, bworld_default: false, shape })).length, 1, JSON.stringify(shape));
|
||||
}
|
||||
// sections of 16, but the generator samples every 32 blocks
|
||||
const shape = { min_y: -48, max_y: 320 };
|
||||
assert(errors({ flat: true, bworld_default: false, shape, cell_height: 32 })[0].includes("cell_height 32"));
|
||||
assert((await errors({ flat: true, bworld_default: false, shape, cell_height: 32 }))[0].includes("cell_height 32"));
|
||||
|
||||
const dir = mods({ flat: true, bworld_default: false, shape, cell_height: 32 });
|
||||
await assertRejects(() => test_game(dir), Error, "flat.json: can't be generated by flat:flat");
|
||||
|
||||
Reference in New Issue
Block a user