Add various generic models

This commit is contained in:
2026-10-12 17:56:47 -03:00
parent e5baeab193
commit d4eff11f3e
34 changed files with 786 additions and 251 deletions
+14 -4
View File
@@ -35,9 +35,21 @@ export interface Remaps {
export const DEFAULT_REMAPS: Remaps = {
textures: { "minecraft:block/": "bworld:", "minecraft:item/": "bworld:" },
models: {},
models: template_remaps(),
};
// minecraft's template models (cube_all, stairs, walls, panes, ...) are the base game's in models/templates, which are
// named after their files
function template_remaps(): Remap {
const dir = new URL("../../mods/bworld/models/templates/", import.meta.url);
return Object.fromEntries(
[...Deno.readDirSync(dir)].filter((entry) => entry.name.endsWith(".json")).map((entry) => {
const name = entry.name.slice(0, -".json".length);
return [`minecraft:block/${name}`, `bworld:${name}`];
}),
);
}
export function remap_location(location: string, remap: Remap = {}): Location {
const full = location_string(parse_location(location));
for (const from of Object.keys(remap).sort((a, b) => b.length - a.length)) {
@@ -192,15 +204,13 @@ export interface Written {
export interface ImportReport {
written: Written[];
// models with no boxes of their own, only there for others to use as a parent
parents: string[];
skipped: { location: string; reason: string }[];
errors: { location: string; problems: string[] }[];
warnings: { location: string; warning: string }[];
}
export function empty_report(): ImportReport {
return { written: [], parents: [], skipped: [], errors: [], warnings: [] };
return { written: [], skipped: [], errors: [], warnings: [] };
}
// two locations that would become the same id are an error, since one would overwrite the other. claim returns false