[PR #5420] [MERGED] Sprint: the server's body carries the sprint modifier; the anticheat replay keeps the client's #6277

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

📋 Pull Request Information

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

Base: main ← Head: fix/anticheat-sprint-modifier


📝 Commits (2)

  • 8bd5ff4 lan_bot: Hub::tick drains the players' packets; bots end their ticks
  • 83e4259 Sprint modifier: the server's body carries it; the replay keeps the client's

📊 Changes

6 files changed (+110 additions, -19 deletions)

View changed files

📝 crates/horizon-anticheat/src/prediction.rs (+13 -6)
📝 crates/horizon-client/src/lan/guest.rs (+15 -3)
📝 crates/horizon-client/src/lan/hub.rs (+13 -2)
📝 crates/horizon-client/src/lan/prediction.rs (+46 -8)
📝 crates/horizon-client/src/motion.rs (+20 -0)
📝 crates/horizon-client/tests/lan_bot.rs (+3 -0)

📄 Description

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

Fixes #5419. Stacked on #5387, which makes lan_bot and clippy pass on main; this PR retargets to main when #5387 merges. Its own change is the last commit.

The server: the sprint modifier on the player's body (vanilla parity)

handlePlayerCommand's START_SPRINTING and STOP_SPRINTING only set a flag on the guest. Vanilla calls setSprinting, which adds or removes the movement speed's minecraft:sprinting modifier (+30%, add_multiplied_total). Without it, the player's movement speed synced with no sprint modifier whenever it changed (a speed or slowness effect, soul speed...). The vanilla client takes the modifiers exactly as sent (ClientPacketListener.handleUpdateAttributes: removeModifiers, then each sent modifier), so it walked while it still sprinted, until the player let go of sprint. The hub now sets the modifier as setSprinting does, so the movement speed syncs it as a vanilla server does.

The anticheat's movement replay

  • Attribute packets. Change::State copied all the server's attributes on any attribute or effect packet, the movement speed included. That dropped the sprint modifier the client kept, so the replay played a sprint as a walk: the false flag of a vanilla client in the 20-minute soak, after a spreadplayers. Now an attribute packet changes the replay's sprint modifier only when it carried the movement speed (Change::Attributes { sprint }, read from the packet), as the client's does.
  • Effect packets copy only the effects (Change::Effects). Their attribute modifiers are the server's and reach the client as attributes.
  • Restarts. A replay that starts from the server's body sprints as the client's first tick does: the body carries the modifier, but the sprint flag only while the game handles the player.

No per-tick cost: one modifier edit per sprint command, and one lookup per attribute packet.

Tests

  • New lan::prediction::tests::attributes_sent_mid_sprint_are_played_as_the_client_takes_them. An attribute packet arrives mid sprint-jump: without the movement speed, with it but no sprint modifier (the client loses its modifier), and with it and the modifier. All three are replayed exactly (≤ 1e-6). Under the old copy-everything rule it fails: tick 33 is 0.03 off.
  • tools/anticheat_e2e.py on a real dedicated server:
    • prediction-vanilla: the vanilla 26.3 client behind 20–120 ms of jitter was never flagged. It walked 259 blocks, sprint-jumping, swimming, gliding, with effects given and cleared.
    • prediction: the honest Horizon client was never flagged; the cheating bot was flagged 13 times and sent back 12 times.
    • combat: passes.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at d6e8bd67a, 14 min 23 s; the scope includes #5387's commit)

Check Result
Scope ✅ 6 files, +114 −25
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 499 passed (4 min 48 s)
rustfmt ✅ (10 s)
clippy ✅ (1 min 20 s)
tests: horizon-anticheat, horizon-client ✅ 1437 passed (5 min 50 s)
doc tests ✅ 0 passed (3 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 ➖ 61 affected, to run in CI (--quick): arrow, auto_jump, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot and 49 more

Clean-room: vanilla 26.3 (ClientPacketListener.handleUpdateAttributes, LivingEntity.setSprinting, ServerGamePacketListenerImpl.handlePlayerCommand), no other project's code.

🤖 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/5420 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/31/2026 **Status:** ✅ Merged **Merged:** 10/31/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/anticheat-sprint-modifier` --- ### 📝 Commits (2) - [`8bd5ff4`](https://github.com/horizon-rust/horizon/commit/8bd5ff4a92f9c95ca9121c59a8e0458b631cdd19) lan_bot: Hub::tick drains the players' packets; bots end their ticks - [`83e4259`](https://github.com/horizon-rust/horizon/commit/83e42596da20e12e0207c55265ccb0cd015ecc2b) Sprint modifier: the server's body carries it; the replay keeps the client's ### 📊 Changes **6 files changed** (+110 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-anticheat/src/prediction.rs` (+13 -6) 📝 `crates/horizon-client/src/lan/guest.rs` (+15 -3) 📝 `crates/horizon-client/src/lan/hub.rs` (+13 -2) 📝 `crates/horizon-client/src/lan/prediction.rs` (+46 -8) 📝 `crates/horizon-client/src/motion.rs` (+20 -0) 📝 `crates/horizon-client/tests/lan_bot.rs` (+3 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #5419. Stacked on #5387, which makes `lan_bot` and clippy pass on main; this PR retargets to main when #5387 merges. Its own change is the last commit. ## The server: the sprint modifier on the player's body (vanilla parity) `handlePlayerCommand`'s START_SPRINTING and STOP_SPRINTING only set a flag on the guest. Vanilla calls `setSprinting`, which adds or removes the movement speed's `minecraft:sprinting` modifier (+30%, `add_multiplied_total`). Without it, the player's movement speed synced with no sprint modifier whenever it changed (a speed or slowness effect, soul speed...). The vanilla client takes the modifiers exactly as sent (`ClientPacketListener.handleUpdateAttributes`: `removeModifiers`, then each sent modifier), so it walked while it still sprinted, until the player let go of sprint. The hub now sets the modifier as `setSprinting` does, so the movement speed syncs it as a vanilla server does. ## The anticheat's movement replay - **Attribute packets.** `Change::State` copied all the server's attributes on any attribute or effect packet, the movement speed included. That dropped the sprint modifier the client kept, so the replay played a sprint as a walk: the false flag of a vanilla client in the 20-minute soak, after a `spreadplayers`. Now an attribute packet changes the replay's sprint modifier only when it carried the movement speed (`Change::Attributes { sprint }`, read from the packet), as the client's does. - **Effect packets** copy only the effects (`Change::Effects`). Their attribute modifiers are the server's and reach the client as attributes. - **Restarts.** A replay that starts from the server's body sprints as the client's first tick does: the body carries the modifier, but the sprint flag only while the game handles the player. No per-tick cost: one modifier edit per sprint command, and one lookup per attribute packet. ## Tests - New `lan::prediction::tests::attributes_sent_mid_sprint_are_played_as_the_client_takes_them`. An attribute packet arrives mid sprint-jump: without the movement speed, with it but no sprint modifier (the client loses its modifier), and with it and the modifier. All three are replayed exactly (≤ 1e-6). Under the old copy-everything rule it fails: tick 33 is 0.03 off. - `tools/anticheat_e2e.py` on a real dedicated server: - `prediction-vanilla`: the vanilla 26.3 client behind 20–120 ms of jitter was never flagged. It walked 259 blocks, sprint-jumping, swimming, gliding, with effects given and cleared. - `prediction`: the honest Horizon client was never flagged; the cheating bot was flagged 13 times and sent back 12 times. - `combat`: passes. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at d6e8bd67a, 14 min 23 s; the scope includes #5387's commit) | Check | Result | | --- | --- | | Scope | ✅ 6 files, +114 −25 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 499 passed (4 min 48 s) | | rustfmt | ✅ (10 s) | | clippy | ✅ (1 min 20 s) | | tests: horizon-anticheat, horizon-client | ✅ 1437 passed (5 min 50 s) | | doc tests | ✅ 0 passed (3 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 | ➖ 61 affected, to run in CI (--quick): arrow, auto_jump, block_removal, command_exec, composter, container_title, crafter, cursor_death, dedicated_server, dispenser, entity_components, entity_death_loot and 49 more | Clean-room: vanilla 26.3 (`ClientPacketListener.handleUpdateAttributes`, `LivingEntity.setSprinting`, `ServerGamePacketListenerImpl.handlePlayerCommand`), no other project's code. 🤖 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 06:17:36 +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#6277
No description provided.