Rename bmod to just mod

This commit is contained in:
2026-11-04 22:07:45 -03:00
parent fe0d857021
commit 5baaf0239a
33 changed files with 253 additions and 253 deletions
+2 -2
View File
@@ -25,7 +25,7 @@ import {
} from "@/common/mod_data.ts";
import { json_object } from "@/common/schema.ts";
import { check_references, load_order, type LoadedMod, type ModReport } from "@/common/mod_check.ts";
import { png_size, texture_size_problem } from "@/common/bmod.ts";
import { png_size, texture_size_problem } from "@/common/mod.ts";
import { type TextureJson, validate_texture_json } from "@/common/texture_animation.ts";
import { type LootTableJson, validate_loot_table } from "@/common/loot.ts";
import { validate_biome } from "@/common/worldgen/biomes.ts";
@@ -125,7 +125,7 @@ function load_mod(mods_dir: string, id: string): LoadedMod {
error(`manifest.json: scripts.${side} ${path} doesn't exist`);
}
}
// cubi/engine needs engine_access, it's checked again on the bundled code when a .bmod loads
// cubi/engine needs engine_access, it's checked again on the bundled code when a .cubi loads
if (mod.manifest?.engine_access !== true) {
const folders = new Set(Object.values(scripts).filter((p) => typeof p === "string").map((p) => dirname(p)));
for (const folder of folders) {
+2 -2
View File
@@ -6,7 +6,7 @@
// converted from the same mod find their textures. a .png.mcmeta becomes the .json next to the png: bworld reads the
// same animation format
import { join } from "@std/path";
import { png_size, texture_size_problem } from "@/common/bmod.ts";
import { png_size, texture_size_problem } from "@/common/mod.ts";
import { type TextureJson, validate_texture_json } from "@/common/texture_animation.ts";
import {
DEFAULT_REMAPS,
@@ -104,7 +104,7 @@ export function import_textures(input: string, options: ImportOptions = {}): Imp
for (const warning of result.warnings) report.warnings.push({ location, warning });
json = result.json;
}
// the limits a .bmod checks, like a title screen's 512×512 panorama being too big
// the limits a .cubi checks, like a title screen's 512×512 panorama being too big
const too_big = texture_size_problem(size, json);
if (too_big) {
report.skipped.push({ location, reason: `it ${too_big}` });
+8 -8
View File
@@ -1,11 +1,11 @@
// SPDX-FileCopyrightText: 2026 Paula Wisnievski
// SPDX-License-Identifier: AGPL-3.0-or-later
// deno task pack-mod mods/copper_tools [copper_tools.bmod]
// builds a mod folder into a .bmod: its data merged into data.json, each script bundled into one module, and its
// deno task pack-mod mods/copper_tools [copper_tools.cubi]
// builds a mod folder into a .cubi: its data merged into data.json, each script bundled into one module, and its
// textures and credits. deno task build does this for every mod in mods/, see docs/modding/gettingstarted/modfiles.md
import { basename, dirname, resolve } from "@std/path";
import { type Bmod, BMOD_EXTENSION, SCRIPT_SIDES, type ScriptSide, write_bmod } from "@/common/bmod.ts";
import { type Mod, MOD_EXTENSION, SCRIPT_SIDES, type ScriptSide, write_mod } from "@/common/mod.ts";
import type { ManifestJson } from "@/common/mod_data.ts";
import { load_and_check, type LoadedMod, mod_deno_config } from "./check_mods.ts";
import { mod_data } from "@/common/mod_check.ts";
@@ -18,10 +18,10 @@ const PLATFORMS: Record<ScriptSide, "deno" | "browser"> = {
shared: "browser",
};
// a mod that passed check-mods, as .bmod bytes
// a mod that passed check-mods, as .cubi bytes
export async function pack_mod(mod: LoadedMod): Promise<Uint8Array<ArrayBuffer>> {
const manifest = mod.manifest as unknown as ManifestJson;
const scripts: Bmod["scripts"] = {};
const scripts: Mod["scripts"] = {};
for (const side of SCRIPT_SIDES) {
const entry = manifest.scripts?.[side];
if (entry) scripts[side] = await bundle_script(mod.dir, `${mod.dir}/${entry}`, PLATFORMS[side]);
@@ -33,7 +33,7 @@ export async function pack_mod(mod: LoadedMod): Promise<Uint8Array<ArrayBuffer>>
}
const texture_json = new Map([...mod.texture_json].sort(([a], [b]) => a.localeCompare(b)));
return write_bmod({
return write_mod({
manifest,
data: mod_data(mod),
scripts,
@@ -75,7 +75,7 @@ async function bundle_script(mod_dir: string, entry: string, platform: "deno" |
if (import.meta.main) {
const [dir, out] = Deno.args;
if (!dir) {
console.error("usage: deno task pack-mod <mod folder> [output.bmod]");
console.error("usage: deno task pack-mod <mod folder> [output.cubi]");
Deno.exit(1);
}
// its siblings are checked too, so references to mods it depends on can be checked
@@ -90,7 +90,7 @@ if (import.meta.main) {
for (const error of mod.report.errors) console.error(` ${error}`);
Deno.exit(1);
}
const file = out ?? `${basename(folder)}${BMOD_EXTENSION}`;
const file = out ?? `${basename(folder)}${MOD_EXTENSION}`;
const bytes = await pack_mod(mod);
Deno.writeFileSync(file, bytes);
console.log(`Packed ${mod.id} into ${file} (${(bytes.length / 1024).toFixed(1)} KB)`);