Fluids on the recipeviewer !
This commit is contained in:
@@ -5,21 +5,23 @@
|
||||
// R and U over any item) opens a screen with the recipes that make it or the ones that use it, like jei's. it only
|
||||
// reads recipes, so it works with any mod's, and draws the ones it has no category for from their json
|
||||
import type { ClientContext } from "bworld/client";
|
||||
import { ItemList, type Mode } from "./item_list.ts";
|
||||
import { type Entry, ItemList, type Mode } from "./item_list.ts";
|
||||
import { RecipeIndex, RecipesScreen } from "./recipes_screen.ts";
|
||||
|
||||
export function setup(ctx: ClientContext) {
|
||||
const index = new RecipeIndex(ctx);
|
||||
const list = new ItemList(ctx);
|
||||
// like jei's IRecipesGui.show, only when there's something to show
|
||||
const open = (item: string, mode: Mode) => {
|
||||
if (index.find(item, mode).length > 0) ctx.ui.open(new RecipesScreen(ctx, index, list, item, mode));
|
||||
const open = (entry: Entry, mode: Mode) => {
|
||||
if (index.find(entry, mode).length > 0) ctx.ui.open(new RecipesScreen(ctx, index, list, entry, mode));
|
||||
};
|
||||
|
||||
// the item list on every menu's screen, right of it
|
||||
ctx.ui.add_inventory_overlay({
|
||||
on_render(g, screen) {
|
||||
const hovered = list.render(g, screen.x + screen.width, open) ?? screen.hovered_item?.id;
|
||||
const slot = screen.hovered_item;
|
||||
const hovered = list.render(g, screen.x + screen.width, open) ??
|
||||
(slot && { kind: "item", id: slot.id } satisfies Entry);
|
||||
if (hovered && g.key_pressed("KeyR")) open(hovered, "recipes");
|
||||
if (hovered && g.key_pressed("KeyU")) open(hovered, "uses");
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user