Loading schematics
This commit is contained in:
@@ -6,6 +6,7 @@ import { check_mods } from "@/tools/check_mods.ts";
|
||||
import { MAX_TEXTURE_SIZE } from "@/common/constants.ts";
|
||||
import { create_mod } from "@/tools/new_mod.ts";
|
||||
import { item_from_json, item_to_json } from "@/common/mod_data.ts";
|
||||
import { encode_schematic } from "@/common/schematic.ts";
|
||||
|
||||
function temp_mods_dir() {
|
||||
const dir = Deno.makeTempDirSync({ prefix: "bworld_mods_" });
|
||||
@@ -127,6 +128,18 @@ Deno.test("check-mods finds broken mods", async () => {
|
||||
new DataView(huge.buffer).setUint32(16, MAX_TEXTURE_SIZE + 1);
|
||||
new DataView(huge.buffer).setUint32(20, 16);
|
||||
Deno.writeFileSync(`${mod}/textures/huge.png`, huge);
|
||||
// a schematic with a block and an entity that don't exist, and a file that isn't a schematic
|
||||
Deno.mkdirSync(`${mod}/schematics`);
|
||||
Deno.writeFileSync(
|
||||
`${mod}/schematics/ghost_hut.cbsm`,
|
||||
encode_schematic({
|
||||
size: [1, 1, 1],
|
||||
palette: [{ id: "broken:no_such_block" }],
|
||||
blocks: [{ i: 0, p: [0, 0, 0] }],
|
||||
entities: [{ p: [0.5, 0, 0.5], id: "broken:no_such_entity", data: {} }],
|
||||
}),
|
||||
);
|
||||
Deno.writeTextFileSync(`${mod}/schematics/notes.cbsm`, "not a schematic");
|
||||
// a script that doesn't typecheck
|
||||
Deno.writeTextFileSync(`${mod}/scripts/main.ts`, "export function client(ctx: number) { ctx.nope(); }\n");
|
||||
// a dependency that isn't installed, and no longer depending on bworld
|
||||
@@ -151,6 +164,9 @@ Deno.test("check-mods finds broken mods", async () => {
|
||||
has(report.errors, `depends on "missing_mod", which isn't installed`);
|
||||
has(report.errors, "entity model broken:no_such_worn doesn't exist");
|
||||
has(report.errors, "worn must be { model, texture }");
|
||||
has(report.errors, "schematics/ghost_hut.cbsm: block broken:no_such_block doesn't exist");
|
||||
has(report.errors, "schematics/ghost_hut.cbsm: entity broken:no_such_entity doesn't exist");
|
||||
has(report.errors, "schematics/notes.cbsm: ");
|
||||
has(report.warnings, "worn model broken:stiff has no bone named like a player part");
|
||||
has(report.warnings, "texture broken:nope doesn't exist");
|
||||
has(report.warnings, `uses bworld:stone but doesn't list "bworld" in dependencies`);
|
||||
|
||||
Reference in New Issue
Block a user