Mod config

This commit is contained in:
2026-10-14 14:14:52 -03:00
parent d7f1b91c0a
commit cedc7725b5
20 changed files with 371 additions and 32 deletions
+9
View File
@@ -247,6 +247,15 @@ function load_mod(mods_dir: string, id: string): LoadedMod {
}
}
if (exists(`${dir}/config.json`)) {
const config = read_json(`${dir}/config.json`, (m) => error(`config.json: ${m}`));
if (!is_object(config) || config.format_version !== FORMAT_VERSION || !is_object(config.config)) {
error(`config.json: must be { "format_version": ${FORMAT_VERSION}, "config": { ... } }`);
} else {
mod.config = config.config;
}
}
// a mod only registers ids in its own namespace
for (const { file, json } of [...mod.blocks, ...mod.models, ...mod.items, ...mod.entities]) {
if (json.id.split(":")[0] !== id) error(`${file}: ${json.id} isn't in this mod's namespace "${id}"`);