Single module modding

This commit is contained in:
2026-11-14 12:18:41 -03:00
parent 605008f584
commit 313098892e
134 changed files with 919 additions and 924 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# Containers
A container is a list of item slots that the server owns and saves: a chest's contents, a furnace's input, fuel and
result, a player's inventory. Server scripts make and use them through `ctx.containers`.
result, a player's inventory. The server phase makes and uses them through `ctx.containers`.
## Making Containers
+8 -8
View File
@@ -2,9 +2,9 @@
Menus are how players use [containers](containers.md), like NeoForge's. A GUI has two halves:
- The **menu** lives in the server script. It decides which slots the player can click, what goes in them, the numbers
- The **menu** lives in the server phase. It decides which slots the player can click, what goes in them, the numbers
the screen shows, what its buttons do, and when it closes.
- The **screen** lives in the client script. It only draws the menu and sends the player's clicks.
- The **screen** lives in the client phase. 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 and cooking pot are all menus, and the base game's curios slots are
@@ -12,13 +12,13 @@ part of [the player's inventory](#the-players-inventory).
## Registering a Menu Type
A menu type is registered in the server script with a function that builds each menu when it opens, like NeoForge's
A menu type is registered in the server phase with a function that builds each menu when it opens, like NeoForge's
`MenuType` and its server menu constructor. It gets the menu to build, whatever the code opening it passes, and the
player:
```ts
// server.ts
export function setup(ctx: ServerContext) {
export function server(ctx: ServerContext) {
const smelter = ctx.menus.register<BlockRef>("copper_tools:smelter", (menu, block, player) => {
const container = ctx.containers.get(block.data.container)!;
menu.title = "Smelter";
@@ -158,12 +158,12 @@ interface MenuHandle {
## Screens
The client script gives each of the mod's menu types a screen, like NeoForge's `RegisterMenuScreensEvent` and
The client phase gives each of the mod's menu types a screen, like NeoForge's `RegisterMenuScreensEvent` and
`AbstractContainerScreen`. The function runs each time one opens, with the client's copy of the menu:
```ts
// client.ts
export function setup(ctx: ClientContext) {
export function client(ctx: ClientContext) {
ctx.ui.register_menu_screen("copper_tools:smelter", (menu) => ({
width: 176,
height: 166,
@@ -215,8 +215,8 @@ 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:
grid, always there while they play. Mods can add slots to it with `ctx.menus.extend_player_menu` while the server phase
runs. The function runs when each player joins:
```ts
ctx.menus.extend_player_menu((menu, player) => {