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
+1
View File
@@ -70,6 +70,7 @@ GUI pixels from the window's top left:
```ts
interface InventoryScreenView {
readonly menu_type: string | undefined; // the open menu's type, undefined on the player's own inventory
readonly x: number;
readonly y: number;
readonly width: number;
+26 -2
View File
@@ -7,7 +7,8 @@ Menus are how players use [containers](containers.md), like NeoForge's. A GUI ha
- The **screen** lives in the client script. It only draws the menu and sends the player's clicks.
Every click goes to the server, which applies it following the menu's rules, so a modified client can only do what the
menu allows. Chests, furnaces, the smithing table, Farmer's Delight's cooking pot and Curios are all menus.
menu allows. Chests, furnaces, the smithing table and Farmer's Delight's cooking pot are all menus, and Curios adds its
slots to [the player's inventory](#the-players-inventory).
## Registering a Menu Type
@@ -179,11 +180,34 @@ interface ClientMenu {
When the server opens a menu type the client has no screen for, the client closes it again, with an error in its
console. A screen that throws is closed the same way.
## The Player's Inventory
The player's own inventory screen is a menu too, menu 0, like Minecraft's `InventoryMenu`: their inventory and crafting
grid, always there while they play. Mods can add slots to it with `ctx.menus.extend_player_menu` during setup. The
function runs when each player joins:
```ts
ctx.menus.extend_player_menu((menu, player) => {
const pouch = pouch_of(player); // a container from ctx.containers, kept for each player
for (let slot = 0; slot < 4; slot++) {
menu.add_slot(pouch, slot, { x: -25, y: 7 + slot * 18 });
}
});
```
`add_slot` takes the same options as a menu's. `x` and `y` are from the inventory screen's top left, and can be outside
it: a negative `x` is left of it. The engine draws a panel behind the slots outside its own, so they need no client
code. Curios puts its slots in 2 columns this way.
Shift clicking in the inventory puts a stack into the first of these slots whose `filter` takes it, before moving it
between the hotbar and the rest of the inventory. Shift clicking one of them moves its stack back into the inventory.
## Messages
How menus go over the network, for anyone working on the engine. Menus have ids from 1 to 100, counting up and around
for each player like Minecraft's. Menu 0 is the player's own inventory (slots 0 to 35, the hotbar first) and crafting
grid (36 to 45), always there and never sent.
grid (36 to 45), always there and never opened. The slots mods added to it come after, from 46: `join` lists their
positions, and the `container` message with `"extra"` syncs what's in them, like the inventory's.
| Message | Way | What |
| -------------------- | ------ | ------------------------------------------------------------------------------- |