Better recipe api and port smithing to it
This commit is contained in:
@@ -57,7 +57,7 @@ import type {
|
||||
ServerContext,
|
||||
SlotOptions,
|
||||
} from "$/common/mod_api/server.ts";
|
||||
import { ModLoadError, shared_recipes_api } from "$/common/mod_loader.ts";
|
||||
import { ModLoadError, recipe_lookup, shared_recipes_api } from "$/common/mod_loader.ts";
|
||||
import {
|
||||
argument,
|
||||
block as block_argument,
|
||||
@@ -303,7 +303,7 @@ export class ModRuntime {
|
||||
this.fluid_rules.register(mod, id, rules);
|
||||
},
|
||||
},
|
||||
recipes: shared_recipes_api(() => this.game.recipes, () => this.#shared_setup, (message) => {
|
||||
recipes: shared_recipes_api(mod, () => this.game.recipes, () => this.#shared_setup, (message) => {
|
||||
throw new ModLoadError(mod, message);
|
||||
}),
|
||||
world: {
|
||||
@@ -1014,12 +1014,7 @@ export class ModRuntime {
|
||||
fuel_value: (item) => game().recipes.fuel.get(item) ?? 0,
|
||||
is_fuel: (item) => game().recipes.fuel.has(item),
|
||||
is_smeltable: (item) => game().recipes.furnace.has(item),
|
||||
smithing: (tool, material, addition) => {
|
||||
const recipe = game().recipes.smithing.find((r) =>
|
||||
r.tool === tool && r.material.id === material && r.addition === addition
|
||||
);
|
||||
return recipe && { result: recipe.result, material_count: recipe.material.count };
|
||||
},
|
||||
...recipe_lookup(() => game().recipes),
|
||||
list: (type) => structuredClone(game().recipes.by_type.get(type) ?? []),
|
||||
},
|
||||
tags: tag_api(),
|
||||
|
||||
Reference in New Issue
Block a user