Register create:compacting recipes for juices
This commit is contained in:
@@ -3,7 +3,8 @@
|
||||
|
||||
// juicing recipes: what the juicer presses an item into. the shared script registers one for every item with
|
||||
// bworld:juiceable, its own juice, and mods can add more like any recipe, as files or from their shared scripts.
|
||||
// whatever makes juice reads them, like the juicer and create's press over a basin
|
||||
// whatever makes juice reads them, like the juicer. with create installed, each is also a create:compacting recipe,
|
||||
// so its press can make juice in a basin
|
||||
import type { FluidVariant, SharedContext, TagApi } from "bworld/shared";
|
||||
import type { JuiceableParams } from "./shared.ts";
|
||||
|
||||
@@ -24,6 +25,21 @@ export function register_juicing(ctx: SharedContext) {
|
||||
const juice = { fluid: { id: "bworld:juice", data: { item: id } }, amount: params.juice };
|
||||
ctx.recipes.register(JUICING, { input: id, fluid_results: [juice] });
|
||||
}
|
||||
if (ctx.blocks.exists("create:mechanical_press") && ctx.blocks.exists("create:basin")) {
|
||||
register_compacting(ctx);
|
||||
}
|
||||
}
|
||||
|
||||
// a create:compacting recipe for every juicing recipe there is so far, so create's press squashes the item into its
|
||||
// juice in a basin under it. create's recipes take a list of item choices and give a list of results, a fluid's as
|
||||
// { fluid, amount }. juicing recipes other mods' shared scripts register later aren't seen here
|
||||
function register_compacting(ctx: SharedContext) {
|
||||
for (const juicing of ctx.recipes.list(JUICING)) {
|
||||
ctx.recipes.register("create:compacting", {
|
||||
ingredients: [juicing.input],
|
||||
results: juicing.fluid_results,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// what reading them needs, which server scripts have
|
||||
|
||||
@@ -192,6 +192,26 @@ Deno.test("the juicer juices by bworld:juicing recipes: one for each juiceable i
|
||||
assertEquals(t.game.world.get_tile(1, 100, 0)?.client_data?.tank, pebble_juice);
|
||||
});
|
||||
|
||||
Deno.test("with create's press and basin there, every juicing recipe is also a create:compacting one", async () => {
|
||||
// every mod in mods/, create among them
|
||||
const { game } = await test_game("mods");
|
||||
const juicing = game.recipes.by_type.get("bworld:juicing")!;
|
||||
const compacting = game.recipes.by_type.get("create:compacting") ?? [];
|
||||
assert(juicing.length > 0);
|
||||
assertEquals(
|
||||
compacting as unknown,
|
||||
juicing.map((recipe) => ({
|
||||
type: "create:compacting",
|
||||
ingredients: [recipe.input],
|
||||
results: recipe.fluid_results,
|
||||
})),
|
||||
);
|
||||
|
||||
// without create there are none
|
||||
const t = await setup();
|
||||
assertEquals(t.game.recipes.by_type.get("create:compacting"), undefined);
|
||||
});
|
||||
|
||||
Deno.test("a broken juicing recipe stops the server from starting", async () => {
|
||||
const broken = {
|
||||
type: "bworld:juicing",
|
||||
|
||||
Reference in New Issue
Block a user