Improve a buuuunch of textures and some reworks

This commit is contained in:
2026-09-27 18:05:20 -03:00
parent 9f47c709f1
commit b7ded817d9
186 changed files with 1486 additions and 124 deletions
+19 -7
View File
@@ -220,8 +220,12 @@ class RecipeViewer {
for (let row = 0; row < 3; row++) {
for (let column = 0; column < 3; column++) {
const letter = recipe.pattern[row]?.[column];
const id = letter && letter !== " " && column < width_in ? recipe.key[letter] : undefined;
cell(id ? { ids: [id], count: 1 } : undefined, x + column * CELL, top + row * CELL);
const choice = letter && letter !== " " && column < width_in ? recipe.key[letter] : undefined;
cell(
choice ? { ids: choice_ids(choice), count: 1 } : undefined,
x + column * CELL,
top + row * CELL,
);
}
}
texture("bworld:arrow_full", x + 3.5 * CELL, top + CELL);
@@ -229,14 +233,14 @@ class RecipeViewer {
break;
}
case "furnace":
cell({ ids: [recipe.input], count: 1 }, x, top);
cell({ ids: choice_ids(recipe.input), count: 1 }, x, top);
texture("bworld:fire_full", x, top + CELL);
texture("bworld:arrow_full", x + 1.5 * CELL, top + CELL / 2);
cell(stack(recipe.output), x + 3 * CELL, top + CELL / 2);
g.text(seconds(recipe.cook_time), x + 1.5 * CELL, top + CELL * 1.5, { color: LABEL_COLOR });
break;
case "fuel":
cell({ ids: [recipe.item], count: 1 }, x, top);
cell({ ids: choice_ids(recipe.item), count: 1 }, x, top);
texture("bworld:fire_full", x, top + CELL);
g.text(`Burns for ${seconds(recipe.burn_time)}`, x + 1.5 * CELL, top + CELL / 2, {
color: LABEL_COLOR,
@@ -296,6 +300,11 @@ function paginate(recipes: Recipe[], height: number): Recipe[][] {
return pages;
}
// shaped keys, furnace inputs and fuels can be one item or a list any of which fits
function choice_ids(choice: string | string[]): string[] {
return typeof choice === "string" ? [choice] : choice;
}
// what a recipe makes
export function outputs(recipe: Recipe): Ingredient[] {
switch (recipe.type) {
@@ -320,11 +329,14 @@ export function outputs(recipe: Recipe): Ingredient[] {
export function inputs(recipe: Recipe): Ingredient[] {
switch (recipe.type) {
case "shaped":
return Object.values(recipe.key as Record<string, string>).map((id) => ({ ids: [id], count: 1 }));
return Object.values(recipe.key as Record<string, string | string[]>).map((choice) => ({
ids: choice_ids(choice),
count: 1,
}));
case "furnace":
return [{ ids: [recipe.input], count: 1 }];
return [{ ids: choice_ids(recipe.input), count: 1 }];
case "fuel":
return [{ ids: [recipe.item], count: 1 }];
return [{ ids: choice_ids(recipe.item), count: 1 }];
case "smithing":
return [{ ids: [recipe.tool], count: 1 }, stack(recipe.material)].concat(
recipe.addition ? [{ ids: [recipe.addition], count: 1 }] : [],