More fluid apis
This commit is contained in:
+14
-3
@@ -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)),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user