[PR #2294] [MERGED] /recipe gives and takes each target's own recipes #4180

Closed
opened 2026-11-03 04:15:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/2294
Author: @ludovic111
Created: 10/26/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @ludovic111

Base: main ← Head: fix/recipe-command-targets


📝 Commits (1)

  • d8e6814 /recipe gives and takes each target's own recipes

📊 Changes

2 files changed (+85 additions, -20 deletions)

View changed files

📝 crates/horizon-client/src/game/commands/world_cmds.rs (+27 -20)
📝 tools/lan_e2e.py (+58 -0)

📄 Description

🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself.

What and why

/recipe give|take <targets> changed self.level.recipe_book for every target. A target other than the player running the command therefore got nothing: the runner's book changed instead (on a dedicated server, the console's, which belongs to nobody), and the target's client heard nothing. Vanilla's RecipeCommand calls ServerPlayer.awardRecipes / resetRecipes on each target's own ServerRecipeBook, which sends that player ClientboundRecipeBookAddPacket / RemovePacket. platform-2 found this.

Each target now runs with its own state swapped in (for_player, as /effect, /tp and /kill already do). The guest's recipe book is in place for the call, and what the call sends goes to that guest's client: the add packet through recipes_unlocked, the remove packet through guest_packets. The counts and feedback don't change.

This covers every path that targets a player who isn't the runner: the server thread (the window's player targeting another), LAN guests (the in-frame host targeting a guest), and the dedicated server's console, which has no player in place, so every target is swapped in, the same call as the in-frame host's.

Testing

New lan_e2e --check recipe_targets. Both players forget every recipe and open their inventory's recipe book. The host gives the guest two recipes by name, the guest gives the host one, and the host takes one of the guest's. After each step, each open book must show exactly its own recipes.

server thread in-frame
main FAIL: host gives guest → host 2, guest 0 FAIL: host gives guest → host 2, guest 0
this PR PASS (host 0→0→1→1, guest 0→2→2→1) PASS (host 0, guest 0→2→2→1)

In-frame, the guest-to-host step is skipped: an in-frame host isn't one of the players a guest's command can name (command_players lists the guests only, and the host's command name is the constant Player). That's a separate gap of the in-frame path, left as it is.

lan_e2e --check recipe_removal still passes in both modes, and so does command_exec, whose corpus has the /recipe cases, against the 26.3 oracle.

Self-check

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 747c22a5c, 10 min 13 s)

Check Result
Scope ✅ 2 files, +85 −20
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ⚠️ 310 run, 2 errors, both macOS-only and on main too: test_parity_runner…test_reuses_until_an_input_or_output_changes (no java mock) and test_rust_parity…test_report_rejects_sources_changed_during_a_run (/private/var vs /var)
rustfmt ✅ (9 s)
clippy ✅ (1 min 9 s)
tests: horizon-client ✅ 1328 passed (7 min 57 s)
Parity command_exec ✅ here; 30 affected, to run in CI

🤖 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/2294 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/26/2026 **Status:** ✅ Merged **Merged:** 10/26/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/recipe-command-targets` --- ### 📝 Commits (1) - [`d8e6814`](https://github.com/horizon-rust/horizon/commit/d8e68148beec68cb857537ebbf0f6ef5b2c46d18) /recipe gives and takes each target's own recipes ### 📊 Changes **2 files changed** (+85 additions, -20 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/commands/world_cmds.rs` (+27 -20) 📝 `tools/lan_e2e.py` (+58 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why `/recipe give|take <targets>` changed `self.level.recipe_book` for every target. A target other than the player running the command therefore got nothing: the runner's book changed instead (on a dedicated server, the console's, which belongs to nobody), and the target's client heard nothing. Vanilla's `RecipeCommand` calls `ServerPlayer.awardRecipes` / `resetRecipes` on each target's own `ServerRecipeBook`, which sends that player `ClientboundRecipeBookAddPacket` / `RemovePacket`. platform-2 found this. Each target now runs with its own state swapped in (`for_player`, as `/effect`, `/tp` and `/kill` already do). The guest's recipe book is in place for the call, and what the call sends goes to that guest's client: the add packet through `recipes_unlocked`, the remove packet through `guest_packets`. The counts and feedback don't change. This covers every path that targets a player who isn't the runner: the server thread (the window's player targeting another), LAN guests (the in-frame host targeting a guest), and the dedicated server's console, which has no player in place, so every target is swapped in, the same call as the in-frame host's. ## Testing New `lan_e2e --check recipe_targets`. Both players forget every recipe and open their inventory's recipe book. The host gives the guest two recipes by name, the guest gives the host one, and the host takes one of the guest's. After each step, each open book must show exactly its own recipes. | | server thread | in-frame | |---|---|---| | main | FAIL: host gives guest → host 2, guest 0 | FAIL: host gives guest → host 2, guest 0 | | this PR | PASS (host 0→0→1→1, guest 0→2→2→1) | PASS (host 0, guest 0→2→2→1) | In-frame, the guest-to-host step is skipped: an in-frame host isn't one of the players a guest's command can name (`command_players` lists the guests only, and the host's command name is the constant `Player`). That's a separate gap of the in-frame path, left as it is. `lan_e2e --check recipe_removal` still passes in both modes, and so does `command_exec`, whose corpus has the `/recipe` cases, against the 26.3 oracle. ## Self-check **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 747c22a5c, 10 min 13 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +85 −20 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ⚠️ 310 run, 2 errors, both macOS-only and on main too: `test_parity_runner…test_reuses_until_an_input_or_output_changes` (no `java` mock) and `test_rust_parity…test_report_rejects_sources_changed_during_a_run` (`/private/var` vs `/var`) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 9 s) | | tests: horizon-client | ✅ 1328 passed (7 min 57 s) | | Parity | `command_exec` ✅ here; 30 affected, to run in CI | 🤖 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 04:15:17 +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#4180
No description provided.