[PR #5026] [MERGED] Native mods: on_equip for /item's main hand, recipes in subfolders, no sends while reconfiguring #6018

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/5026
Author: @Qwerner88880
Created: 10/31/2026
Status: ✅ Merged
Merged: 10/31/2026
Merged by: @levzzz5154

Base: main ← Head: fix-native-followups


📝 Commits (2)

  • d4b98b9 Native mods: on_equip for /item's main hand, recipes in subfolders, no sends while reconfiguring
  • 9cf6a6d Recipes load in id order, unreadable folders warn, the book reads subfolders

📊 Changes

7 files changed (+94 additions, -53 deletions)

View changed files

📝 crates/horizon-client/src/crafting.rs (+53 -20)
📝 crates/horizon-client/src/game/commands/items.rs (+13 -1)
📝 crates/horizon-client/src/game/native_hooks.rs (+3 -2)
📝 crates/horizon-client/src/game/native_net.rs (+2 -1)
📝 crates/horizon-client/src/game/remote.rs (+1 -1)
📝 crates/horizon-client/src/recipe_book.rs (+14 -13)
📝 crates/horizon-client/src/stations.rs (+8 -15)

📄 Description

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

What and why

Fixes #5016. Part of #3911 (Mods). Three small things left from the reviews of #4677, #4838 and #4669. No new hook or helper, so NATIVE_HOOKS_API stays.

  • native_on_equip for /item's main hand: /item replace entity @p weapon.mainhand with ... told nothing, while the swap-hands key reports the main hand. It now goes through player_on_equip, as the armor slots already do. hotbar.N stays a plain inventory write, even when N is the selected slot, as in vanilla, where that path is Inventory.setItem.
  • A content mod's recipes in a subfolder: data/mymod/recipe/crushing/iron.json was skipped, while the same path in a data pack loads. Recipes::load and StationRecipes::load now share recipe_files, which walks the folder and names the recipe mymod:crushing/iron. Files load in id order (crushing before crushing/iron), as vanilla lists resources in a map keyed by id; a folder that can't be listed is warned and skipped, as PathPackResources keeps what it found. A follow-up commit from the review also points the recipe book's index at the same recursive walk, so vanilla's brewing/ recipes (minecraft:brewing/<name>, no display of their own) get ids there.
  • native_net_send_to_server while reconfiguring: it answered Ok, although the connection is out of the play state then. It now answers "the player has not joined yet", as it does before the first join.
  • native_item_dropped's doc says what scatters at death isn't this hook.

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

  • /item: SlotAccess for weapon.mainhand goes to LivingEntity.setItemSlot, which calls onEquipItem. hotbar.N goes to Inventory.setItem, which doesn't.
  • Subfolders: RecipeManager lists recipe/ recursively, through SimpleJsonResourceReloadListener, and the id keeps the path. lan/recipes.rs already walks it this way.
  • Sends: ClientboundStartConfigurationPacket takes the connection out of play, and the native API is Horizon-only.

The game's jars are on this machine (server-game.jar and the others, under the main checkout's .local), and the /item references above were read from the bytecode with javap; tools/rea_vanilla.py wasn't run (it needs the worktree's .local linked), and neither was parity — CI's parity job picks the harnesses that cover these files. CI's parity job picks the harnesses that cover these files.

Other projects' code

none

Tests

Unit test: custom_recipes_load_by_type_with_pack_override now has data/mymod/recipe/deep/er/d.json, expecting mymod:deep/er/d.

Live, on this branch rebased on main: a throwaway mixin bundle on a dedicated server with two horizon-ctl --offscreen clients.

  • /item: weapon.mainhand gives on_equip mainhand, taking a helmet off gives None, and hotbar.N gives no on_equip. All 62 checks of the run pass, including the older message, item and signal hooks.
  • Mob helpers from #4799 as merged: this isn't changed here, but I ran my scenario on levzzz's version, and all 39 checks pass. It includes the refusals: a monster on peaceful, outside the world's bounds, an unloaded chunk and a level other than the one in place, with the mob left alone afterwards.

Not run live:

  • A send during a real reconfiguration. Horizon's own server never sends StartConfiguration (only a test in net.rs does), so it takes another server, and I didn't set one up. This check is read from the code: reconfiguring is set on Event::Reconfiguring and cleared when play starts again.
  • A station recipe in a subfolder. The unit test covers Recipes::load, and StationRecipes::load uses the same recipe_files.

Self-check

pr_ready (tools/pr_ready.py --quick on DESKTOP-H7P5E7K, against origin/main at 9d979caa4, 3 min 1 s)

Check Result
Scope ✅ 6 files, +64 −40
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 495 passed (1 min 9 s)
rustfmt ✅ (7 s)
clippy ✅ (30 s)
tests: horizon-client ✅ 1330 passed (1 min 10 s)
doc tests ✅ 0 passed (1 s)
content root tests ➖ content root untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 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/5026 **Author:** [@Qwerner88880](https://github.com/Qwerner88880) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-native-followups` --- ### 📝 Commits (2) - [`d4b98b9`](https://github.com/horizon-rust/horizon/commit/d4b98b96b04ed13f4bf5686065893202dd2166f7) Native mods: on_equip for /item's main hand, recipes in subfolders, no sends while reconfiguring - [`9cf6a6d`](https://github.com/horizon-rust/horizon/commit/9cf6a6d154eacb8a5652671807c7d078fde25650) Recipes load in id order, unreadable folders warn, the book reads subfolders ### 📊 Changes **7 files changed** (+94 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/crafting.rs` (+53 -20) 📝 `crates/horizon-client/src/game/commands/items.rs` (+13 -1) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+3 -2) 📝 `crates/horizon-client/src/game/native_net.rs` (+2 -1) 📝 `crates/horizon-client/src/game/remote.rs` (+1 -1) 📝 `crates/horizon-client/src/recipe_book.rs` (+14 -13) 📝 `crates/horizon-client/src/stations.rs` (+8 -15) </details> ### 📄 Description > 🤖 Opened by Qwerner88880's AI agent (Claude Code, Claude Opus 5.5), not by Qwerner88880 personally. ## What and why Fixes #5016. Part of #3911 (Mods). Three small things left from the reviews of #4677, #4838 and #4669. No new hook or helper, so `NATIVE_HOOKS_API` stays. - **`native_on_equip` for `/item`'s main hand:** `/item replace entity @p weapon.mainhand with ...` told nothing, while the swap-hands key reports the main hand. It now goes through `player_on_equip`, as the armor slots already do. `hotbar.N` stays a plain inventory write, even when N is the selected slot, as in vanilla, where that path is `Inventory.setItem`. - **A content mod's recipes in a subfolder:** `data/mymod/recipe/crushing/iron.json` was skipped, while the same path in a data pack loads. `Recipes::load` and `StationRecipes::load` now share `recipe_files`, which walks the folder and names the recipe `mymod:crushing/iron`. Files load in id order (`crushing` before `crushing/iron`), as vanilla lists resources in a map keyed by id; a folder that can't be listed is warned and skipped, as `PathPackResources` keeps what it found. A follow-up commit from the review also points the recipe book's index at the same recursive walk, so vanilla's `brewing/` recipes (`minecraft:brewing/<name>`, no display of their own) get ids there. - **`native_net_send_to_server` while reconfiguring:** it answered `Ok`, although the connection is out of the play state then. It now answers "the player has not joined yet", as it does before the first join. - **`native_item_dropped`'s doc** says what scatters at death isn't this hook. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] 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 - **`/item`:** `SlotAccess` for `weapon.mainhand` goes to `LivingEntity.setItemSlot`, which calls `onEquipItem`. `hotbar.N` goes to `Inventory.setItem`, which doesn't. - **Subfolders:** `RecipeManager` lists `recipe/` recursively, through `SimpleJsonResourceReloadListener`, and the id keeps the path. `lan/recipes.rs` already walks it this way. - **Sends:** `ClientboundStartConfigurationPacket` takes the connection out of play, and the native API is Horizon-only. The game's jars are on this machine (`server-game.jar` and the others, under the main checkout's `.local`), and the `/item` references above were read from the bytecode with `javap`; `tools/rea_vanilla.py` wasn't run (it needs the worktree's `.local` linked), and neither was parity — CI's parity job picks the harnesses that cover these files. CI's parity job picks the harnesses that cover these files. ## Other projects' code none ## Tests **Unit test:** `custom_recipes_load_by_type_with_pack_override` now has `data/mymod/recipe/deep/er/d.json`, expecting `mymod:deep/er/d`. **Live, on this branch rebased on main:** a throwaway mixin bundle on a dedicated server with two `horizon-ctl --offscreen` clients. - **`/item`:** `weapon.mainhand` gives `on_equip mainhand`, taking a helmet off gives `None`, and `hotbar.N` gives no `on_equip`. All 62 checks of the run pass, including the older message, item and signal hooks. - **Mob helpers from #4799 as merged:** this isn't changed here, but I ran my scenario on levzzz's version, and all 39 checks pass. It includes the refusals: a monster on peaceful, outside the world's bounds, an unloaded chunk and a level other than the one in place, with the mob left alone afterwards. **Not run live:** - A send during a real reconfiguration. Horizon's own server never sends `StartConfiguration` (only a test in `net.rs` does), so it takes another server, and I didn't set one up. This check is read from the code: `reconfiguring` is set on `Event::Reconfiguring` and cleared when play starts again. - A station recipe in a subfolder. The unit test covers `Recipes::load`, and `StationRecipes::load` uses the same `recipe_files`. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on DESKTOP-H7P5E7K, against origin/main at 9d979caa4, 3 min 1 s) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +64 −40 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 495 passed (1 min 9 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (30 s) | | tests: horizon-client | ✅ 1330 passed (1 min 10 s) | | doc tests | ✅ 0 passed (1 s) | | content root tests | ➖ content root untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 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:16:39 +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#6018
No description provided.