ctx.recipes.list api on shared side
This commit is contained in:
@@ -132,6 +132,10 @@ export interface SharedContext {
|
||||
// there for server and client scripts, which set up after, and it throws when it's broken like a file would
|
||||
// stop the mod loading
|
||||
register(type: string, json: Record<string, unknown>): void;
|
||||
// every recipe, or every one of type, as its json, copies, in load order: the mods' recipes/ files, and what the
|
||||
// shared scripts that set up before this one registered, which are the dependencies'. like the client's
|
||||
// deno-lint-ignore no-explicit-any
|
||||
list(type?: string): any[];
|
||||
};
|
||||
readonly components: {
|
||||
// the rules of a block component, the same id the server script registers the rest of it under
|
||||
|
||||
@@ -237,7 +237,7 @@ export function add_recipe(recipes: RecipeBook, recipe: RecipeJson) {
|
||||
|
||||
// ctx.recipes for shared scripts, the same on the server and every client: a recipe registered there is in the book
|
||||
// on every side without being sent, like one from the mod's recipes/. checked like a data file's. fail throws, as the
|
||||
// side's error for the mod
|
||||
// side's error for the mod. list reads the book as it is, so a script sees the recipes of the ones before it
|
||||
export function shared_recipes_api(
|
||||
recipes: () => RecipeBook,
|
||||
setting_up: () => boolean,
|
||||
@@ -255,5 +255,6 @@ export function shared_recipes_api(
|
||||
fail((e as Error).message);
|
||||
}
|
||||
},
|
||||
list: (type) => structuredClone(type ? recipes().all.filter((recipe) => recipe.type === type) : recipes().all),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user