[GH-ISSUE #5246] Native mods: menu_button lacks vanilla clickMenuButton's player (carried stack) #1609

Closed
opened 2026-11-02 15:48:21 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Sylviromi on GitHub (Oct 31, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5246

Originally assigned to: @Sylviromi on GitHub.

🤖 Filed by Sylviromi's AI agent (Claude Code, Claude Sonnet 5), not by Sylviromi personally.

What a mod cannot do. A native mod's own screen (ModContainer) can draw widgets outside the registered
slots (a tank, a filter slot, an upgrade/ghost slot), but a click on one of those widgets reaches the server
only as a button id. Vanilla's counterpart is AbstractContainerMenu.clickMenuButton(Player player, int id),
which a NeoForge mod's menu overrides directly (there is no NeoForge event for it); vanilla hands the method
the acting player, so an overridden clickMenuButton can read and set the cursor stack through
player.containerMenu.getCarried()/setCarried(). Horizon's hook for this moment has no player at all, so a
widget cannot take or offer the cursor item the way vanilla's own menus can (dropping a bucket onto a drawn
tank, copying the cursor stack into a filter slot).

Why the existing hooks do not reach it. native_screen_click (crates/horizon-client/src/game/native_hooks.rs:866-874)
is client-only, fires only when the click lands outside any registered slot, and only sets a button: &mut Option<i32> — no item data. The ContainerButtonClick packet it triggers (native_hooks.rs:2250-2256) carries
only {container, button}. Server-side, mod_menu_button resolves the block entity and calls
native_menu_button(pos, entity, id) (native_hooks.rs:892-898, called from lan_stations.rs:395-424 /
native_hooks.rs:2206-2219) — the signature vanilla's clickMenuButton would need is (player, id); Horizon's
has neither the acting player nor the carried stack. The server does track a per-guest carried stack
(crates/horizon-client/src/lan/containers.rs:389-390, 655-656, 741-743), but mod_menu_button never reads it
or passes the clicking player through. native_menu_clicked (native_hooks.rs:927-935) is a different,
narrower feature: it only fires for menus opened by native_open_menu (a mod's plain vanilla-chest "look-at"
menu), never for a ModContainer block screen.

Proposed hook. No new hook name: give menu_button the payload vanilla's clickMenuButton already has —
the acting player's carried stack, either as carried: &mut Option<ItemStack> sourced from the clicking
guest's carried stack at the existing call site (lan_stations.rs:411, native_hooks.rs:2206-2219, and
single-player's equivalent), or by swapping the acting player in for the call the way other "acting player"
hooks already do (per AGENTS.md's "Mixin facts", a hook for the acting player swaps that player in only
during the call), so native_carried_stack-style helpers reach it directly. Fires server-side, same moment as
today's native_menu_button. Not cancellable (additive read/write, same as the existing entity mutation).
Per docs/native-hooks-neoforge.md rule 6, a merged hook's name and parameters are frozen, so this is a new
hook version — menu_button_v2 (or a new catalog version entry for menu_button) — with its API number
given at merge, per rule 7 ("API next").

Who already wants it. Any mod with a custom-drawn widget on its own ModContainer screen that should
accept or offer the cursor stack: a tank widget that takes a bucket or fluid cell, a filter slot that copies
the cursor item, an upgrade/ghost slot that previews a carried item without consuming it. This is generic to
ModContainer, not specific to any one mod. No open issue or PR covers this (closest, unrelated: #5056, follow-ups from the block-entity/screen hook reviews, does not mention carried stacks).

Workaround. None through the screen today. The interim path is a right-click on the block itself
(native_right_click_block, reading the held item through native_carried_stack), which only reaches the
hotbar/inventory stack, not the menu's floating cursor stack a screen click needs.

Originally created by @Sylviromi on GitHub (Oct 31, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/5246 Originally assigned to: @Sylviromi on GitHub. > 🤖 Filed by Sylviromi's AI agent (Claude Code, Claude Sonnet 5), not by Sylviromi personally. **What a mod cannot do.** A native mod's own screen (`ModContainer`) can draw widgets outside the registered slots (a tank, a filter slot, an upgrade/ghost slot), but a click on one of those widgets reaches the server only as a button id. Vanilla's counterpart is `AbstractContainerMenu.clickMenuButton(Player player, int id)`, which a NeoForge mod's menu overrides directly (there is no NeoForge event for it); vanilla hands the method the acting player, so an overridden `clickMenuButton` can read and set the cursor stack through `player.containerMenu.getCarried()`/`setCarried()`. Horizon's hook for this moment has no player at all, so a widget cannot take or offer the cursor item the way vanilla's own menus can (dropping a bucket onto a drawn tank, copying the cursor stack into a filter slot). **Why the existing hooks do not reach it.** `native_screen_click` (`crates/horizon-client/src/game/native_hooks.rs:866-874`) is client-only, fires only when the click lands outside any registered slot, and only sets a `button: &mut Option<i32>` — no item data. The `ContainerButtonClick` packet it triggers (`native_hooks.rs:2250-2256`) carries only `{container, button}`. Server-side, `mod_menu_button` resolves the block entity and calls `native_menu_button(pos, entity, id)` (`native_hooks.rs:892-898`, called from `lan_stations.rs:395-424` / `native_hooks.rs:2206-2219`) — the signature vanilla's `clickMenuButton` would need is `(player, id)`; Horizon's has neither the acting player nor the carried stack. The server does track a per-guest carried stack (`crates/horizon-client/src/lan/containers.rs:389-390, 655-656, 741-743`), but `mod_menu_button` never reads it or passes the clicking player through. `native_menu_clicked` (`native_hooks.rs:927-935`) is a different, narrower feature: it only fires for menus opened by `native_open_menu` (a mod's plain vanilla-chest "look-at" menu), never for a `ModContainer` block screen. **Proposed hook.** No new hook name: give `menu_button` the payload vanilla's `clickMenuButton` already has — the acting player's carried stack, either as `carried: &mut Option<ItemStack>` sourced from the clicking guest's carried stack at the existing call site (`lan_stations.rs:411`, `native_hooks.rs:2206-2219`, and single-player's equivalent), or by swapping the acting player in for the call the way other "acting player" hooks already do (per `AGENTS.md`'s "Mixin facts", a hook for the acting player swaps that player in only during the call), so `native_carried_stack`-style helpers reach it directly. Fires server-side, same moment as today's `native_menu_button`. Not cancellable (additive read/write, same as the existing `entity` mutation). Per `docs/native-hooks-neoforge.md` rule 6, a merged hook's name and parameters are frozen, so this is a new hook version — `menu_button_v2` (or a new catalog `version` entry for `menu_button`) — with its API number given at merge, per rule 7 ("API next"). **Who already wants it.** Any mod with a custom-drawn widget on its own `ModContainer` screen that should accept or offer the cursor stack: a tank widget that takes a bucket or fluid cell, a filter slot that copies the cursor item, an upgrade/ghost slot that previews a carried item without consuming it. This is generic to `ModContainer`, not specific to any one mod. No open issue or PR covers this (closest, unrelated: #5056, follow-ups from the block-entity/screen hook reviews, does not mention carried stacks). **Workaround.** None through the screen today. The interim path is a right-click on the block itself (`native_right_click_block`, reading the held item through `native_carried_stack`), which only reaches the hotbar/inventory stack, not the menu's floating cursor stack a screen click needs.
Author
Owner

@Sylviromi commented on GitHub (Oct 31, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6545915185 --> @Sylviromi commented on GitHub (Oct 31, 2026): 🤖 Agent: /claim
Author
Owner

@github-actions[bot] commented on GitHub (Oct 31, 2026):

🤖 Claims: refused, You already hold this issue. (asked by @Sylviromi)

<!-- gh-comment-id:6545966256 --> @github-actions[bot] commented on GitHub (Oct 31, 2026): 🤖 Claims: refused, You already hold this issue. (asked by @Sylviromi)
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#1609
No description provided.