Change curios to always show on inventory
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 |
|
||||
| -------------------- | ------ | ------------------------------------------------------------------------------- |
|
||||
|
||||
@@ -28,9 +28,9 @@ server and worldgen scripts), delivery to clients (hashed downloads, the confirm
|
||||
data layer (blocks, block models with variants, items, recipes including mods' own types, entities and entity models,
|
||||
ores), server scripts (components, events, commands, timers, storage, recipes, containers, displayed items), menus like
|
||||
NeoForge's (menu types, slots, data, buttons and `still_valid` on the server, menu screens on the client, and the
|
||||
player's inventory as menu 0), client scripts (item and recipe lookups, plain screens, inventory overlays, `Graphics` in
|
||||
GUI pixels), mod channels, worldgen features and ores, the base game's block behavior and screens as a mod, and world
|
||||
time. See [Menus](modding/inventories/menus.md) and [Screens](modding/gui/index.md).
|
||||
player's inventory as menu 0, which mods can add slots to), client scripts (item and recipe lookups, plain screens,
|
||||
inventory overlays, `Graphics` in GUI pixels), mod channels, worldgen features and ores, the base game's block behavior
|
||||
and screens as a mod, and world time. See [Menus](modding/inventories/menus.md) and [Screens](modding/gui/index.md).
|
||||
|
||||
The code is in `common/mod_loader.ts`, `common/mod_data.ts`, `common/mod_check.ts`, `common/bmod.ts`,
|
||||
`server/game/mod_runtime.ts`, `server/game/menu.ts`, `server/load_bmods.ts`, `client/mods.ts`, `client/menu.ts` and
|
||||
|
||||
Reference in New Issue
Block a user