[PR #7406] [MERGED] A console command's effect reaches the player at its full duration #7582

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7406
Author: @Akirabane
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7115-console-effect-sync


📝 Commits (4)

  • 29fe5ed Send an effect a console command gives at its full duration
  • 947f63b Test that an effect synced after its command is sent once at 600
  • 112c4e4 Merge remote-tracking branch 'origin/main' into fix/7115-console-effect-sync
  • c7a4d4b Merge remote-tracking branch 'origin/main' into fix/7115-console-effect-sync

📊 Changes

2 files changed (+115 additions, -0 deletions)

View changed files

📝 crates/horizon-client/src/game/dedicated.rs (+8 -0)
📝 crates/horizon-client/src/lan/hub.rs (+107 -0)

📄 Description

🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review.

Fixes #7115

What was wrong

server_player_targets passed at the last nightly audit that ran it (2026-11-01, a1fa1ac0a6, run 41291782912: PASS server_player_targets 152s) and failed at b9721a295 (run 41420192897). The 2026-11-02 07:37Z run in between ran nothing (its DST guard). The only difference is in step=console-effect: after effect give Bob minecraft:speed 30 1 from the dedicated server's console, Bob got effect minecraft:speed 1 599 where vanilla sends 600.

The harness has not changed since 2026-10-26, so the cause is in the game. 354e2e632 (#6404, "Send mining drops in the tick they are created") moved tick_guests ahead of hub.tick_level in tick_lan (lan.rs 2280 → 2325 became 2178 → 2281), so mining drops go out in the tick that made them. As a side effect, the guests' effects now count down (guest_server_tick → tick_mob_effects) before the hub syncs them (tick_level ends with sync_effects). The dedicated console runs at the start of the loop and never synced effects itself. So the effect it gave was counted down once, and only then sent, at 599. A player's own commands were not affected: run_guest_command already calls sync_all_effects right after the command, which is why alice-effect-all still matched.

Vanilla (javap of the pinned 26.3 server-game.jar):

  • DedicatedServer.tickConnection is MinecraftServer.tickConnection() then handleConsoleInputs(), so the console runs after the levels and connections have ticked the players (MinecraftServer.tickChildren: ServerLevel.tick, then tickConnection, then PlayerList.tick);
  • ServerPlayer.onEffectAdded builds a ClientboundUpdateMobEffectPacket and sends it at once, at the full duration (30 s = 600 ticks); the next tick counts it down without sending (LivingEntity.tickEffects refreshes only at a multiple of 600 left).

What changed

console_command (dedicated.rs) calls hub.sync_all_effects() after a command goes to the game's dispatcher or a mod, the same call run_guest_command, the integrated owner's console and the command harness already make. The effect leaves at 600, before the next tick counts it down. sync_effects does not resend an effect that only counted down, so no packet is sent twice. The stdin console, RCON (rcon_line → console_line_telling → console_command) and the control socket's console request all pass through console_command. #6404's tick order is unchanged, and potions, beacons, golden apples and players' commands keep their current paths.

How it was checked

  • Read and compared, not run: the parity harness needs the maintainers' runner and does not run on Windows. The diagnosis is by git blame and the two audits' logs, as above.
  • New unit test in lan/hub.rs: a hub with one guest and speed (30 s × 20 = 600, vanilla's duration). Synced right after it is given, then two ticks: the guest is sent exactly [600]. Synced only after one tick, the order main had for the console: [599], #7115's transcript. The values come from vanilla's command and tick rules, not from this code.
  • Not covered by a test: the call inside console_command itself. There is no fixture that builds a dedicated Game in unit tests; the parity job's server_player_targets run on this PR is the end-to-end check.

Self-check

python3 tools/pr_ready.py --quick --base origin/main:

Check Result
Scope ✅ 2 files, +115 −0
Cargo.lock ✅ unchanged
Public tree ✅
rustfmt ✅
clippy ✅
tests: horizon-client, horizon-client-lib ✅ 2149 passed
mod API up to date ✅
Python tests ❌ local only: tests/test_port_ledger.py cannot import tests.test_class_index under unittest discover -s tests on this Windows machine; no Python file is touched here
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses

🤖 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/7406 **Author:** [@Akirabane](https://github.com/Akirabane) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7115-console-effect-sync` --- ### 📝 Commits (4) - [`29fe5ed`](https://github.com/horizon-rust/horizon/commit/29fe5ed4db34cb0b7dcf982fec6c7cb8eba672df) Send an effect a console command gives at its full duration - [`947f63b`](https://github.com/horizon-rust/horizon/commit/947f63bb12b95eafd394e1349cab752fdcd1d145) Test that an effect synced after its command is sent once at 600 - [`112c4e4`](https://github.com/horizon-rust/horizon/commit/112c4e4906c8ab8a280576e0e1adcea26246b544) Merge remote-tracking branch 'origin/main' into fix/7115-console-effect-sync - [`c7a4d4b`](https://github.com/horizon-rust/horizon/commit/c7a4d4bc0016b8f9b746f6eaa63608f09524b48f) Merge remote-tracking branch 'origin/main' into fix/7115-console-effect-sync ### 📊 Changes **2 files changed** (+115 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dedicated.rs` (+8 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+107 -0) </details> ### 📄 Description > 🤖 Opened by both Akirabane's AI agent (Claude Code), and Akirabane Himself after his review. Fixes #7115 ## What was wrong `server_player_targets` passed at the last nightly audit that ran it (2026-11-01, `a1fa1ac0a6`, run 41291782912: `PASS server_player_targets 152s`) and failed at `b9721a295` (run 41420192897). The 2026-11-02 07:37Z run in between ran nothing (its DST guard). The only difference is in `step=console-effect`: after `effect give Bob minecraft:speed 30 1` from the dedicated server's console, Bob got `effect minecraft:speed 1 599` where vanilla sends `600`. The harness has not changed since 2026-10-26, so the cause is in the game. 354e2e632 (#6404, "Send mining drops in the tick they are created") moved `tick_guests` ahead of `hub.tick_level` in `tick_lan` (lan.rs 2280 → 2325 became 2178 → 2281), so mining drops go out in the tick that made them. As a side effect, the guests' effects now count down (`guest_server_tick` → `tick_mob_effects`) before the hub syncs them (`tick_level` ends with `sync_effects`). The dedicated console runs at the start of the loop and never synced effects itself. So the effect it gave was counted down once, and only then sent, at 599. A player's own commands were not affected: `run_guest_command` already calls `sync_all_effects` right after the command, which is why `alice-effect-all` still matched. Vanilla (javap of the pinned 26.3 `server-game.jar`): - `DedicatedServer.tickConnection` is `MinecraftServer.tickConnection()` then `handleConsoleInputs()`, so the console runs after the levels and connections have ticked the players (`MinecraftServer.tickChildren`: `ServerLevel.tick`, then `tickConnection`, then `PlayerList.tick`); - `ServerPlayer.onEffectAdded` builds a `ClientboundUpdateMobEffectPacket` and sends it at once, at the full duration (30 s = 600 ticks); the next tick counts it down without sending (`LivingEntity.tickEffects` refreshes only at a multiple of 600 left). ## What changed `console_command` (dedicated.rs) calls `hub.sync_all_effects()` after a command goes to the game's dispatcher or a mod, the same call `run_guest_command`, the integrated owner's console and the command harness already make. The effect leaves at 600, before the next tick counts it down. `sync_effects` does not resend an effect that only counted down, so no packet is sent twice. The stdin console, RCON (`rcon_line` → `console_line_telling` → `console_command`) and the control socket's `console` request all pass through `console_command`. #6404's tick order is unchanged, and potions, beacons, golden apples and players' commands keep their current paths. ## How it was checked - Read and compared, not run: the parity harness needs the maintainers' runner and does not run on Windows. The diagnosis is by `git blame` and the two audits' logs, as above. - New unit test in `lan/hub.rs`: a hub with one guest and speed (30 s × 20 = 600, vanilla's duration). Synced right after it is given, then two ticks: the guest is sent exactly `[600]`. Synced only after one tick, the order main had for the console: `[599]`, #7115's transcript. The values come from vanilla's command and tick rules, not from this code. - Not covered by a test: the call inside `console_command` itself. There is no fixture that builds a dedicated `Game` in unit tests; the parity job's `server_player_targets` run on this PR is the end-to-end check. ## Self-check `python3 tools/pr_ready.py --quick --base origin/main`: | Check | Result | | --- | --- | | Scope | ✅ 2 files, +115 −0 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | tests: horizon-client, horizon-client-lib | ✅ 2149 passed | | mod API up to date | ✅ | | Python tests | ❌ local only: `tests/test_port_ledger.py` cannot import `tests.test_class_index` under `unittest discover -s tests` on this Windows machine; no Python file is touched here | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | 🤖 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 07:20: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#7582
No description provided.