Change curios to always show on inventory

This commit is contained in:
2026-10-01 16:35:41 -03:00
parent deba36260e
commit 3dc7d2adee
24 changed files with 244 additions and 159 deletions
+7 -4
View File
@@ -1,7 +1,7 @@
// the client's copy of a menu, like neoforge's client menu: built from what the server sent when it opened, kept up
// to date with what it syncs. clicks go to the server, which decides what they do
import { Container } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT, type MenuSlotInfo, PLAYER_MENU, PLAYER_MENU_CRAFTING } from "$/common/protocol.ts";
import { CRAFTING_RESULT_SLOT, type MenuSlotInfo, PLAYER_MENU, PLAYER_MENU_EXTRA } from "$/common/protocol.ts";
import type { ClientInventories } from "./inventory.ts";
export interface ClientSlot {
@@ -61,8 +61,8 @@ export class ClientMenu {
}
}
// menu 0, the player's inventory and crafting grid, laid out for the inventory screen. its slots are the player's
// own containers, which the server syncs whether or not a menu is open
// menu 0, the player's inventory and crafting grid, laid out for the inventory screen, then the slots mods added. its
// slots are the player's own containers, which the server syncs whether or not a menu is open
export function player_menu(inventories: ClientInventories): ClientMenu {
const slot = (container: Container, index: number, x: number, y: number, output = false): ClientSlot => ({
container,
@@ -81,6 +81,9 @@ export function player_menu(inventories: ClientInventories): ClientMenu {
slots.push(slot(inventories.crafting, i, 25 + (i % 3) * 18, 16 + Math.floor(i / 3) * 18));
}
slots.push(slot(inventories.crafting, CRAFTING_RESULT_SLOT, 115, 34, true));
if (slots.length !== PLAYER_MENU_CRAFTING + CRAFTING_RESULT_SLOT + 1) throw new Error("menu 0 has the wrong slots");
if (slots.length !== PLAYER_MENU_EXTRA) throw new Error("menu 0 has the wrong slots");
for (const [i, info] of inventories.extra_slots.entries()) {
slots.push({ ...slot(inventories.extra, i, info.x, info.y, info.output === true), icon: info.icon });
}
return new ClientMenu(PLAYER_MENU, "", "Crafting", null, slots);
}