[PR #5938] [MERGED] Anticheat prediction: the server's sprinting flag reaches the replay #6573

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

📋 Pull Request Information

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

Base: main ← Head: fix/ac-sprint-one-tick


📝 Commits (1)

  • 2a1dd55 Anticheat prediction: the server's sprinting flag reaches the replay

📊 Changes

4 files changed (+87 additions, -1 deletions)

View changed files

📝 crates/horizon-anticheat/src/prediction.rs (+5 -0)
📝 crates/horizon-client/src/lan/guest.rs (+7 -0)
📝 crates/horizon-client/src/lan/prediction.rs (+74 -0)
📝 docs/anticheat.md (+1 -1)

📄 Description

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

Fixes #5935.

What happens. On the official server, the prediction check logs about 200 lines in 40 minutes, from many different honest players, all with the same signature: 1 tick, ground sprinting, keys forward sprint, about 0.045 blocks off along the direction of motion, moved 0.25–0.28.

Cause (vanilla 26.3: ClientPacketListener.handleSetEntityData / handleUpdateAttributes, LocalPlayer.aiStep, sendIsSprintingIfNeeded, LivingEntity.setSprinting):

  1. The client stops sprinting for a tick and then starts again. STOP_SPRINTING and START_SPRINTING reach the server in two different server ticks.
  2. For the STOP, the server sends the player its own shared flags (sprinting bit cleared) and its movement speed without the sprint modifier. They reach the client after it is already sprinting again.
  3. The client takes both. Its flag is clear, so canStartSprinting() is true and the next aiStep calls setSprinting(true) with the sprint key held, which adds the modifier back. wasSprinting never changed, so it sends nothing.
  4. The replay applied the attributes but not the flag. It went on "sprinting" without the modifier until the START's attributes reached it, at walking acceleration: 0.0294 off on the first tick (under the 0.03 tolerance), then 0.0455 on the second. That is the live line exactly, and 0.054 if a third tick passes before the START's attributes arrive.

Fix. Change::Sprinting: the sprinting bit of the shared flags the server sends the player itself, recorded like the other changes. The replay sets its flag alone from it, as assignValues does, so its sprint phase starts the sprint again with the modifier, as the client did. The same change is faithful the other way too: a sprinting bit the server sets reaches the replay as it reaches the client.

Tests (lan::prediction):

  • a_sprint_the_server_cleared_is_started_again: the client lets go of forward for one tick and then sprints again. The STOP's flags and attributes reach it 1, 2 or 3 ticks later, and the START's 1 or 2 ticks after those. It is played again exactly. Before the fix it fails with offset 0.0294, state ground sprinting, and the (3, 2) case gives 0.0294, 0.0455 (one tick counted at 0.045, as on the live server).
  • a_speed_lie_through_a_sprint_restart_still_counts: the same run with a +0.05/tick speed lie starting on the tick the STOP's packets arrive. It counts from that tick on, on most ticks.

The existing tests, including a_small_speed_lie_kept_up_still_counts and a_faster_or_flying_client_is_not, are unchanged and pass.

Related pattern, not fixed here. About 176 lines show ground (not sprinting) with keys forward sprint, with offsets that grow to 0.064 a tick. This looks like the server's own sprint stop after a sprint hit (causeExtraKnockback). The client starts its sprint again silently, but the record takes tick.sprinting from the server's player (g.sprinting), not from the client's own PlayerCommands. That needs a separate small fix: record the commanded sprint separately.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at 8c02c0b85, 6 min 27 s)

Check Result
Scope ✅ 4 files, +87 −1
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 515 passed (1 min 12 s)
rustfmt ✅ (5 s)
clippy ✅ (1 min 17 s)
tests: horizon-anticheat, horizon-client ✅ 1711 passed (3 min 19 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 ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more
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/5938 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/ac-sprint-one-tick` --- ### 📝 Commits (1) - [`2a1dd55`](https://github.com/horizon-rust/horizon/commit/2a1dd555d0adc31ccac459b9b1e2a0413efb6e56) Anticheat prediction: the server's sprinting flag reaches the replay ### 📊 Changes **4 files changed** (+87 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-anticheat/src/prediction.rs` (+5 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+7 -0) 📝 `crates/horizon-client/src/lan/prediction.rs` (+74 -0) 📝 `docs/anticheat.md` (+1 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #5935. **What happens.** On the official server, the prediction check logs about 200 lines in 40 minutes, from many different honest players, all with the same signature: `1 tick`, `ground sprinting`, `keys forward sprint`, about 0.045 blocks off along the direction of motion, `moved` 0.25–0.28. **Cause** (vanilla 26.3: `ClientPacketListener.handleSetEntityData` / `handleUpdateAttributes`, `LocalPlayer.aiStep`, `sendIsSprintingIfNeeded`, `LivingEntity.setSprinting`): 1. The client stops sprinting for a tick and then starts again. STOP_SPRINTING and START_SPRINTING reach the server in two different server ticks. 2. For the STOP, the server sends the player its own shared flags (sprinting bit cleared) and its movement speed without the sprint modifier. They reach the client after it is already sprinting again. 3. The client takes both. Its flag is clear, so `canStartSprinting()` is true and the next `aiStep` calls `setSprinting(true)` with the sprint key held, which adds the modifier back. `wasSprinting` never changed, so it sends nothing. 4. The replay applied the attributes but not the flag. It went on "sprinting" without the modifier until the START's attributes reached it, at walking acceleration: 0.0294 off on the first tick (under the 0.03 tolerance), then 0.0455 on the second. That is the live line exactly, and 0.054 if a third tick passes before the START's attributes arrive. **Fix.** `Change::Sprinting`: the sprinting bit of the shared flags the server sends the player itself, recorded like the other changes. The replay sets its flag alone from it, as `assignValues` does, so its sprint phase starts the sprint again with the modifier, as the client did. The same change is faithful the other way too: a sprinting bit the server sets reaches the replay as it reaches the client. **Tests** (`lan::prediction`): - `a_sprint_the_server_cleared_is_started_again`: the client lets go of forward for one tick and then sprints again. The STOP's flags and attributes reach it 1, 2 or 3 ticks later, and the START's 1 or 2 ticks after those. It is played again exactly. Before the fix it fails with `offset 0.0294, state ground sprinting`, and the (3, 2) case gives `0.0294, 0.0455` (one tick counted at 0.045, as on the live server). - `a_speed_lie_through_a_sprint_restart_still_counts`: the same run with a +0.05/tick speed lie starting on the tick the STOP's packets arrive. It counts from that tick on, on most ticks. The existing tests, including `a_small_speed_lie_kept_up_still_counts` and `a_faster_or_flying_client_is_not`, are unchanged and pass. **Related pattern, not fixed here.** About 176 lines show `ground` (not sprinting) with `keys forward sprint`, with offsets that grow to 0.064 a tick. This looks like the server's own sprint stop after a sprint hit (`causeExtraKnockback`). The client starts its sprint again silently, but the record takes `tick.sprinting` from the server's player (`g.sprinting`), not from the client's own PlayerCommands. That needs a separate small fix: record the commanded sprint separately. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at 8c02c0b85, 6 min 27 s) | Check | Result | | --- | --- | | Scope | ✅ 4 files, +87 −1 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 515 passed (1 min 12 s) | | rustfmt | ✅ (5 s) | | clippy | ✅ (1 min 17 s) | | tests: horizon-anticheat, horizon-client | ✅ 1711 passed (3 min 19 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 | ➖ 34 affected, to run in CI (--quick): block_removal, command_exec, composter, crafter, cursor_death, dedicated_server, dispenser, forced_end, friends_integration, hardcore_respawn, lan_integration, locator_bar and 22 more | | 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 06:23:14 +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#6573
No description provided.