[PR #4072] [MERGED] Native mods: menus for mod containers (vanilla slot grids and furnaces) #5399

Closed
opened 2026-11-03 05:12:19 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4072
Author: @Sylviromi
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @levzzz5154

Base: main ← Head: native-mod-menus


📝 Commits (7)

  • def1dbe Native mods: a mod container opens a vanilla slot menu
  • 3cb4177 Native mods: furnace menus for mod containers, with their data slots
  • b916a49 Merge branch 'native-mod-inventories' into native-mod-menus
  • 51b39ee Merge branch 'native-mod-inventories' into native-mod-menus
  • aba4ee3 Native mods: a mod menu shows only its container's slots
  • 0e573b8 Merge native-mod-inventories; menus are API 6
  • 76ab943 Merge main; menus for mod containers are API 17

📊 Changes

10 files changed (+201 additions, -34 deletions)

View changed files

📝 crates/horizon-client-render/src/chunk/block_entity.rs (+26 -4)
📝 crates/horizon-client-render/src/containers.rs (+2 -2)
📝 crates/horizon-client/src/game.rs (+3 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+11 -3)
📝 crates/horizon-client/src/game/machines.rs (+1 -0)
📝 crates/horizon-client/src/game/native_hooks.rs (+68 -21)
📝 crates/horizon-client/src/lan/containers.rs (+2 -0)
📝 crates/horizon-client/src/lan/menu.rs (+79 -3)
📝 crates/horizon-client/src/save.rs (+6 -1)
📝 docs/native-mods.md (+3 -0)

📄 Description

🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Opus 5.5), not by Sylviromi personally.

Stacked on #4055 (itself on #3996): review only the commits after #4055 (def1dbef3 and 3cb417702, +114 −31 in all).

What and why

Fixes #4070. Part of #3911 (Mods): the simplest screen for a mod container (gap "M, menus and screens" in #1854), with no new client code.

  • ModContainer.menu: a vanilla menu that is a plain slot grid (containers::MOD_MENUS: minecraft:hopper, generic_3x3, generic_9x1 to generic_9x6) with as many slots as the container; any other is left out when the containers are read.
  • Using the block (its template opens a menu, as a chest or a furnace does) opens it: open_menu grows the block entity's slots to the menu's and marks it the open container, and the server hands it to the player as it does a chest (lan_open_container), so single player on the server thread, LAN guests and servers' players get the same OpenScreen and slot clicks that vanilla's containers use (lan::menu::Slots::Block).
  • Its title is the block's name (Block.getDescriptionId, block.<namespace>.<path>), or the block entity's custom name.
  • Furnace menus (3cb417702): minecraft:furnace, blast_furnace and smoker too (3 slots). Their four data slots come from the block entity's new data (set by the mod's tick, never saved) and are sent as a furnace's are (AbstractFurnaceBlockEntity.dataAccess, ContainerSetData): the flame is data[0] of data[1], the arrow data[2] of data[3], so a machine shows its energy and its progress. Menus with rules of their own (brewing stand, crafter) stay out.
  • The tick hook takes the block entity whole: native_block_entity_tick(pos, entity: &mut ModBlockEntity) (id, nbt, items, data), so fields added later don't change its signature again. API 6, unreleased.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Horizon-only (the native mod API), using vanilla's HopperMenu / DispenserMenu / ChestMenu layouts as they are, and Block.getDescriptionId for the title. Without a mod nothing changes.

Self-check

New test native_hooks::tests::mod_menus_are_slot_grids_and_furnaces.

pr_ready (tools/pr_ready.py --quick, against origin/main at 829c4021a; the scope includes #3996 and #4055)

Check Result
Scope ✅ 15 files, +448 −29
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 475 passed
rustfmt ✅
clippy ✅
tests: horizon-client, horizon-client-render ❌ 688 passed, 1 failed: the axolotl test of #3840 (runs only with prepared resources; passes in CI)
doc tests ✅
Parity ➖ not run (--quick)

Proof

The test mod of #3996 / #4055, now five slots (input from the top and the sides, output from the bottom) with menu: "minecraft:hopper". Offscreen through horizon-ctl, single player on the server thread: a hopper fed it 20 iron ore, then interact on the block gave "screen": "container":

The menu (a hopper's: one row of five slots over the inventory) is titled "Tick Counter" (the mod's block.testmachine.counter) and shows the machine's slots live: its output slot holds the 12 ore it had moved by then.

Furnace menu, with a machine mod (the stack with #4055's slots and the next PR's neighbour helper): a GregTech-style LV macerator opens a furnace menu titled "Basic Macerator (LV)" whose flame shows its stored energy (15,998 of 16,000 EU) and whose arrow shows its progress (200 ticks per ore), both moving as it works (offscreen, through horizon-ctl).

Not covered: LAN guests and dedicated servers (the same lan_open_container path). Sylviromi tested the hopper-grid menu by hand in a window (clicking items in and out, hoppers, comparators, droppers): it works; the furnace menus are proven offscreen only.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/4072 **Author:** [@Sylviromi](https://github.com/Sylviromi) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `native-mod-menus` --- ### 📝 Commits (7) - [`def1dbe`](https://github.com/horizon-rust/horizon/commit/def1dbef33291cc0eae0b2952080d8197f3b4467) Native mods: a mod container opens a vanilla slot menu - [`3cb4177`](https://github.com/horizon-rust/horizon/commit/3cb4177026f7fdb6ef7d19b46632ed59dca33dad) Native mods: furnace menus for mod containers, with their data slots - [`b916a49`](https://github.com/horizon-rust/horizon/commit/b916a49fbf57dd043de70a9ea34f3a068dce3bad) Merge branch 'native-mod-inventories' into native-mod-menus - [`51b39ee`](https://github.com/horizon-rust/horizon/commit/51b39ee118eb168b83e17281ffbc581d060cf1b2) Merge branch 'native-mod-inventories' into native-mod-menus - [`aba4ee3`](https://github.com/horizon-rust/horizon/commit/aba4ee3d568051c410388c5a9d859614e5e56f96) Native mods: a mod menu shows only its container's slots - [`0e573b8`](https://github.com/horizon-rust/horizon/commit/0e573b8e25e0b4b77ac89686593c9c00d514d06e) Merge native-mod-inventories; menus are API 6 - [`76ab943`](https://github.com/horizon-rust/horizon/commit/76ab943b4096b2495efc81eacec070b6b27315bc) Merge main; menus for mod containers are API 17 ### 📊 Changes **10 files changed** (+201 additions, -34 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-render/src/chunk/block_entity.rs` (+26 -4) 📝 `crates/horizon-client-render/src/containers.rs` (+2 -2) 📝 `crates/horizon-client/src/game.rs` (+3 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+11 -3) 📝 `crates/horizon-client/src/game/machines.rs` (+1 -0) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+68 -21) 📝 `crates/horizon-client/src/lan/containers.rs` (+2 -0) 📝 `crates/horizon-client/src/lan/menu.rs` (+79 -3) 📝 `crates/horizon-client/src/save.rs` (+6 -1) 📝 `docs/native-mods.md` (+3 -0) </details> ### 📄 Description > 🤖 Opened by Sylviromi's AI agent (Claude Code, Claude Opus 5.5), not by Sylviromi personally. **Stacked on #4055 (itself on #3996): review only the commits after #4055** (`def1dbef3` and `3cb417702`, +114 −31 in all). ## What and why Fixes #4070. Part of #3911 (Mods): the simplest screen for a mod container (gap "M, menus and screens" in #1854), with no new client code. - `ModContainer.menu`: a vanilla menu that is a plain slot grid (`containers::MOD_MENUS`: `minecraft:hopper`, `generic_3x3`, `generic_9x1` to `generic_9x6`) with as many slots as the container; any other is left out when the containers are read. - Using the block (its template opens a menu, as a chest or a furnace does) opens it: `open_menu` grows the block entity's slots to the menu's and marks it the open container, and the server hands it to the player as it does a chest (`lan_open_container`), so single player on the server thread, LAN guests and servers' players get the same `OpenScreen` and slot clicks that vanilla's containers use (`lan::menu::Slots::Block`). - Its title is the block's name (`Block.getDescriptionId`, `block.<namespace>.<path>`), or the block entity's custom name. - **Furnace menus** (`3cb417702`): `minecraft:furnace`, `blast_furnace` and `smoker` too (3 slots). Their four data slots come from the block entity's new `data` (set by the mod's tick, never saved) and are sent as a furnace's are (`AbstractFurnaceBlockEntity.dataAccess`, `ContainerSetData`): the flame is `data[0]` of `data[1]`, the arrow `data[2]` of `data[3]`, so a machine shows its energy and its progress. Menus with rules of their own (brewing stand, crafter) stay out. - **The tick hook takes the block entity whole**: `native_block_entity_tick(pos, entity: &mut ModBlockEntity)` (id, nbt, items, data), so fields added later don't change its signature again. API 6, unreleased. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [x] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Horizon-only (the native mod API), using vanilla's `HopperMenu` / `DispenserMenu` / `ChestMenu` layouts as they are, and `Block.getDescriptionId` for the title. Without a mod nothing changes. ## Self-check New test `native_hooks::tests::mod_menus_are_slot_grids_and_furnaces`. **pr_ready** (`tools/pr_ready.py --quick`, against origin/main at 829c4021a; the scope includes #3996 and #4055) | Check | Result | | --- | --- | | Scope | ✅ 15 files, +448 −29 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 475 passed | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-render | ❌ 688 passed, 1 failed: the axolotl test of #3840 (runs only with prepared resources; passes in CI) | | doc tests | ✅ | | Parity | ➖ not run (--quick) | ## Proof The test mod of #3996 / #4055, now five slots (input from the top and the sides, output from the bottom) with `menu: "minecraft:hopper"`. Offscreen through `horizon-ctl`, single player on the server thread: a hopper fed it 20 iron ore, then `interact` on the block gave `"screen": "container"`: The menu (a hopper's: one row of five slots over the inventory) is titled "Tick Counter" (the mod's `block.testmachine.counter`) and shows the machine's slots live: its output slot holds the 12 ore it had moved by then. **Furnace menu, with a machine mod** (the stack with #4055's slots and the next PR's neighbour helper): a GregTech-style LV macerator opens a furnace menu titled "Basic Macerator (LV)" whose flame shows its stored energy (15,998 of 16,000 EU) and whose arrow shows its progress (200 ticks per ore), both moving as it works (offscreen, through `horizon-ctl`). Not covered: LAN guests and dedicated servers (the same `lan_open_container` path). Sylviromi tested the hopper-grid menu by hand in a window (clicking items in and out, hoppers, comparators, droppers): it works; the furnace menus are proven offscreen only. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:12:19 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5399
No description provided.