Stonecutter

This commit is contained in:
2026-10-12 20:52:41 -03:00
parent 02cbeda0a0
commit bea5f10a12
20 changed files with 411 additions and 6 deletions
+1
View File
@@ -44,6 +44,7 @@ export class GuiModMenuScreen extends GuiMenuScreen {
get data() {
return menu.data;
},
item: (slot) => menu.item(slot),
click_button: (id) => {
if (!Number.isInteger(id)) throw new Error(`a menu button is a whole number, not ${id}`);
if (self.screen && client.screens.includes(self.screen)) {
+8
View File
@@ -6,6 +6,7 @@
import { Container } from "$/common/inventory.ts";
import { CRAFTING_RESULT_SLOT, type MenuSlotInfo, PLAYER_MENU, PLAYER_MENU_EXTRA } from "$/common/protocol.ts";
import type { ClientInventories } from "./inventory.ts";
import type { ItemStack as ApiItemStack } from "$/common/mod_api/client.ts";
export interface ClientSlot {
// where its item is on this client
@@ -46,6 +47,13 @@ export class ClientMenu {
this.data = data;
}
// what's in a slot, by menu slot index, the way mods see items. a copy
item(slot: number): ApiItemStack | undefined {
const info = this.slots[slot];
const item = info?.container.get_item(info.index);
return item && { id: item.type_id, count: item.amount, data: structuredClone(item.data) };
}
// one the server opened: its slots' items come in menu_content, into a container of its own
static opened(id: number, type: string, title: string, open_data: unknown, slots: MenuSlotInfo[]) {
const items = new Container(slots.length);