Sounds on the client

This commit is contained in:
2026-11-22 07:21:29 -03:00
parent f308ab52f1
commit 47934b272c
21 changed files with 1002 additions and 25 deletions
+6 -1
View File
@@ -3,7 +3,7 @@
// deno task pack-mod mods/copper_tools [copper_tools.cubi]
// builds a mod folder into a .cubi: its data merged into data.json, its 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
// textures, sounds 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 { MOD_EXTENSION, write_mod } from "@/common/mod.ts";
import type { ManifestJson } from "@/common/mod_data.ts";
@@ -20,6 +20,10 @@ export async function pack_mod(mod: LoadedMod): Promise<Uint8Array<ArrayBuffer>>
textures.set(id, Deno.readFileSync(path));
}
const texture_json = new Map([...mod.texture_json].sort(([a], [b]) => a.localeCompare(b)));
const sounds = new Map<string, Uint8Array>();
for (const [path, file] of [...mod.sound_files].sort(([a], [b]) => a.localeCompare(b))) {
sounds.set(path, Deno.readFileSync(file));
}
// without what the content phase registered, which the server registers again when it loads the .cubi
const data = mod_data(mod);
@@ -30,6 +34,7 @@ export async function pack_mod(mod: LoadedMod): Promise<Uint8Array<ArrayBuffer>>
script,
textures,
texture_json,
sounds,
credits: manifest.credits ? Deno.readTextFileSync(`${mod.dir}/${manifest.credits}`) : undefined,
});
}