Every recipe type registered from shared scripts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 21:00:44 -03:00
co-authored by Claude Opus 5.5
parent 65113862f7
commit a7e81b9944
25 changed files with 334 additions and 371 deletions
+13 -7
View File
@@ -67,13 +67,17 @@ export interface RecipeType<R, I> {
matches(recipe: R, input: I): boolean;
}
// reads a field of a recipe's json for RecipeType.parse, checked like the engine's own recipes' fields. throws naming
// the field when it isn't one, or its item isn't registered
// reads a value from a recipe's json for RecipeType.parse, checked like the engine's own recipes' fields. name is where
// it is, like "result" or "ingredients[0]", for the error thrown when it isn't one, or what it names isn't registered
export interface RecipeReader {
item(json: Record<string, unknown>, field: string): Id;
stack(json: Record<string, unknown>, field: string): { id: Id; count: number };
item(value: unknown, name: string): Id;
stack(value: unknown, name: string): { id: Id; count: number };
// an item, a #tag or a list of them, any of which fits, as every item that does, like the engine's shaped keys
ingredient(json: Record<string, unknown>, field: string): Id[];
ingredient(value: unknown, name: string): Id[];
// { fluid, amount } in mB
fluid_stack(value: unknown, name: string): FluidStack;
// a whole number, at least 1, like a time in ticks
positive_int(value: unknown, name: string): number;
}
// the recipes of registered types, as their parse made them, in load order. not to be changed
@@ -156,7 +160,8 @@ export interface SharedContext {
// what one sells for, from its "base_sell_value", or undefined if it can't be sold
sell_value(id: Id): number | undefined;
};
readonly fluids: {
// every fluid any mod defines, like the server's and clients' ctx.fluids, without what rules decide
readonly fluids: Pick<FluidApi, "exists" | "same"> & {
// the rules of one of the mod's fluids, which the server and every client name and color it by
register(id: Id, rules: FluidRules): void;
};
@@ -172,7 +177,8 @@ export interface SharedContext {
// deno-lint-ignore no-explicit-any
list(type?: string): any[];
// a recipe type of the mod's own, in its namespace, only during setup: its recipes, from files and register,
// are parsed by it then, and find and all read them from there on every side. see RecipeType
// are parsed by it then, and find and all read them from there on every side. a recipe of a type no mod
// registers stops its mod loading once every shared script has set up. see RecipeType
register_type<R, I>(type: Id, rules: RecipeType<R, I>): void;
} & RecipeLookup;
readonly components: {