Tooltip api

This commit is contained in:
2026-11-05 23:06:37 -03:00
parent 9bc8fd992a
commit 34f001285d
15 changed files with 264 additions and 81 deletions
+14
View File
@@ -17,6 +17,7 @@ import type {
Visual,
VisualBlock,
} from "cubi/client";
import { TOOLTIP_PRIORITY } from "cubi/client";
import { MINIGAMES } from "./minigames/mod.ts";
import { JUICER_CAPACITY, JUICER_PRESSES } from "./shared.ts";
import { STONECUTTING, stonecutting_options, type StonecuttingRecipe } from "./stonecutting.ts";
@@ -24,6 +25,8 @@ import { STONECUTTING, stonecutting_options, type StonecuttingRecipe } from "./s
const WIDTH = 176;
// like minecraft's 176x166 container screens
const HEIGHT = 166;
// what an item sells for, after its food line in its tooltip
const VALUE_COLOR: Color = [0.95, 0.8, 0.3, 1];
export function setup(ctx: ClientContext) {
ctx.ui.register_menu_screen("bworld:storage", chest_screen);
@@ -36,6 +39,17 @@ export function setup(ctx: ClientContext) {
ctx.ui.register_menu_screen("bworld:fishing_minigame", fishing_minigame_screen);
ctx.render.register_visual("bworld:juicer", juicer_visual);
ctx.ui.add_item_tooltip((item, lines) => {
const value = ctx.items.sell_value(item.id, item.data);
if (value === undefined) return;
lines.push({
icon: "bworld:copper_coin",
text: String(value),
color: VALUE_COLOR,
priority: TOOLTIP_PRIORITY.food + 1,
});
});
ctx.ui.register_menu_screen("bworld:cooking_pot", (menu) => ({
width: WIDTH,
height: HEIGHT,