More fluid apis

This commit is contained in:
2026-10-28 13:04:24 -03:00
parent 1539cf6933
commit 3cc33ea10c
7 changed files with 36 additions and 4 deletions
+14 -3
View File
@@ -117,6 +117,12 @@ export function predict_neighbors(x: number, y: number, z: number) {
let recipe_book = new RecipeBook();
const mod_names = new Map<string, string>();
// the name of the mod whose namespace an id is in, or the namespace when no loaded mod has it
function mod_name(id: string) {
const namespace = id.split(":")[0];
return mod_names.get(namespace) ?? namespace;
}
export function set_mods_client(game_client: Client) {
client = game_client;
}
@@ -343,12 +349,17 @@ function client_context(listing: ModListing): ClientContext {
ids: () => EverythingRegistry.entries("items").map(([id]) => id),
mod(id) {
known_item(id);
const namespace = id.split(":")[0];
return mod_names.get(namespace) ?? namespace;
return mod_name(id);
},
},
blocks: blocks_api(mod),
fluids: fluid_rules.api(),
fluids: {
...fluid_rules.api(),
mod(id) {
if (!EverythingRegistry.get("fluids", id)) throw new Error(`[${mod}] unknown fluid ${id}`);
return mod_name(id);
},
},
loot: {
table: (id) => structuredClone(EverythingRegistry.get<LootTableJson>("loot_tables", id)),
},