Stonecutter
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user