Juicer recipes register

This commit is contained in:
2026-10-30 22:35:44 -03:00
parent 43521b3675
commit 4717e45a9a
9 changed files with 171 additions and 42 deletions
+4 -15
View File
@@ -161,7 +161,7 @@ function base_categories(tags: TagApi): RecipeCategory[] {
},
},
{
// what the juicer presses an item into, see juicing_recipes
// what the juicer presses an item into, see JUICING
type: JUICING,
title: "Juicing",
width: 116,
@@ -169,7 +169,7 @@ function base_categories(tags: TagApi): RecipeCategory[] {
catalysts: [JUICER],
draw(recipe, layout) {
const [{ fluid, amount }] = fluid_outputs(recipe);
layout.slot({ ids: [recipe.input], count: 1 }, 0, 0);
layout.slot({ ids: tags.expand(recipe.input), count: 1 }, 0, 0);
layout.texture("bworld:arrow_full", 31, 1, ARROW, ARROW);
layout.fluid(fluid, amount, 60, 0);
layout.text(`${amount} mB`, 82, 5);
@@ -178,22 +178,11 @@ function base_categories(tags: TagApi): RecipeCategory[] {
];
}
// the base game's juicer, from the items with bworld:juiceable: a recipe of its own type for each, that presses one
// of it into its juice. the item is an input like any recipe's, the juice is its fluid result, with the item it's from as
// its data like the juicer makes it
// the base game's juicer's recipes, which press an item into a fluid, its "fluid_results". bworld registers one for
// every item with bworld:juiceable, see mods/bworld/scripts/juicing.ts
const JUICING = "bworld:juicing";
const JUICER = "bworld:juicer";
export function juicing_recipes(ctx: ClientContext): Recipe[] {
if (!ctx.fluids.exists("bworld:juice")) return [];
return ctx.items.ids().flatMap((id) => {
const params = ctx.items.components(id)["bworld:juiceable"] as { juice?: number } | undefined;
if (!params?.juice) return [];
const juice = { fluid: { id: "bworld:juice", data: { item: id } }, amount: params.juice };
return [{ type: JUICING, input: id, fluid_results: [juice] }];
});
}
// the base game's fish, the items with bworld:fish, as recipes of their own type that make them, so clicking one shows
// when and where it bites. their params are under "fish", which reading a recipe's inputs skips
const FISHING = "bworld:fishing";
@@ -9,7 +9,6 @@ import type { ClientContext, Graphics, Screen } from "bworld/client";
import {
crabpot_recipes,
fishing_recipes,
juicing_recipes,
make_categories,
type RecipeCategory,
type RecipeLayout,
@@ -56,7 +55,6 @@ export class RecipeIndex {
...this.ctx.recipes.list(),
...fishing_recipes(this.ctx),
...crabpot_recipes(this.ctx),
...juicing_recipes(this.ctx),
];
this.#categories = make_categories(this.ctx, this.#recipes);
}