All the stone cutter recipes

This commit is contained in:
2026-10-12 21:07:06 -03:00
parent bea5f10a12
commit dfc6a6d77b
521 changed files with 5052 additions and 60 deletions
+8 -4
View File
@@ -26,16 +26,20 @@ interface RecipeReader {
export function stonecutting_recipes(ctx: RecipeReader): StonecuttingRecipe[] {
return ctx.recipes.list(STONECUTTING).map((json, i) => {
const where = `${STONECUTTING} recipe ${i + 1}`;
const choice = json.input;
const input = typeof choice === "string" || Array.isArray(choice) ? ctx.tags.expand(choice) : [];
if (input.length === 0 || !input.every((id) => ctx.items.exists(id))) {
// a tag can be empty, like one of another mod's items that isn't installed
const choice: unknown = json.input;
const entries = typeof choice === "string" ? [choice] : Array.isArray(choice) ? choice : [];
const exists = (entry: unknown) =>
typeof entry === "string" &&
(entry.startsWith("#") ? ctx.tags.exists("items", entry.slice(1)) : ctx.items.exists(entry));
if (entries.length === 0 || !entries.every(exists)) {
throw new Error(`${where}: input must be an item, a #tag or a list of them, and they must exist`);
}
const { id, count } = json.output ?? {};
if (typeof id !== "string" || !ctx.items.exists(id) || !Number.isInteger(count) || count < 1) {
throw new Error(`${where}: output must be { id, count } of an item that exists`);
}
return { input, output: { id, count } };
return { input: ctx.tags.expand(choice as string | string[]), output: { id, count } };
});
}