Register recipe api

This commit is contained in:
2026-10-28 23:56:29 -03:00
parent 5d64b801a3
commit 43521b3675
9 changed files with 235 additions and 42 deletions
+10
View File
@@ -111,6 +111,8 @@ export interface SharedContext {
// every item any mod registered, like the client's ctx.items, for rules that read one, like a juice named after the
// fruit it's from
readonly items: {
// every item, in load order, like the server's ctx.items.ids
ids(): Id[];
exists(id: Id): boolean;
// what players see, like "Cooked Rice"
name(id: Id): string;
@@ -123,6 +125,14 @@ export interface SharedContext {
// 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;
};
readonly recipes: {
// adds a recipe of type, like "shaped" or "farmersdelight:cooking", as a file in the mod's recipes/ with that
// json would, only during setup. for recipes made from other data, like one for every item with a component.
// shared scripts run on the server and every client alike, so they all have it without it being sent. it's
// 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;
};
readonly components: {
// the rules of a block component, the same id the server script registers the rest of it under
// deno-lint-ignore no-explicit-any