[PR #4735] [CLOSED] Anticheat: the speed check #5817

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4735
Author: @ludovic111
Created: 10/30/2026
Status: ❌ Closed

Base: main ← Head: feat/anticheat-speed


📝 Commits (1)

  • 5be58cf Anticheat: the speed check

📊 Changes

12 files changed (+407 additions, -12 deletions)

View changed files

📝 crates/horizon-anticheat/src/lib.rs (+12 -0)
➕ crates/horizon-anticheat/src/speed.rs (+217 -0)
📝 crates/horizon-bots/src/main.rs (+17 -2)
📝 crates/horizon-client/src/game/lan_actions.rs (+1 -4)
📝 crates/horizon-client/src/game/lan_mobs.rs (+1 -5)
📝 crates/horizon-client/src/game/lan_particles.rs (+1 -0)
📝 crates/horizon-client/src/lan/anticheat.rs (+84 -0)
📝 crates/horizon-client/src/lan/chunks.rs (+22 -0)
📝 crates/horizon-client/src/lan/guest.rs (+12 -0)
📝 crates/horizon-client/src/lan/hub.rs (+8 -0)
📝 docs/anticheat.md (+1 -0)
📝 tools/anticheat_e2e.py (+31 -1)

📄 Description

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

What and why

The dedicated server's anticheat gets a speed check: moving sideways faster than vanilla allows (speed hacks). Off unless [anticheat] is in server.toml. Vanilla only refuses moves of more than 10 blocks a tick ("moved too quickly"), so anything slower passes.

Vanilla's own movement code is the limit (LivingEntity.travelInAir, Player.getFlyingSpeed, jumpFromGround), taken at its largest (crates/horizon-anticheat/src/speed.rs, unit-tested). A move is at most:

  • the previous move (at most what the rule allowed then) times the friction it carries into this tick: the block's friction × 0.91 if that tick started on the ground, else 0.91;
  • plus this tick's acceleration: the movement speed attribute (effects included) × 1.3 (as if sprinting) × 0.216 / friction³ on the ground, 0.026 in the air;
  • plus 0.2 if the tick starts on the ground and goes up (a sprint jump);
  • or more, if the server pushed the player: the largest push from SetEntityMotion and explosions, fading over about a second for the round trip;
  • counted per client tick: the ClientTickEnds since the last move, since a still client skips moves.

Ice (up to blue ice's 0.989) and slime (0.8) have their own friction, read from a new flag on the chunk encoder's block states. On top comes tolerance, 0.05 blocks. Not judged: water and lava (currents, Depth Strider, Dolphin's Grace), gliding, Riptide, creative and spectators, vehicles, and the move after a teleport.

On stone, the limit levels off at vanilla's sprint, 0.286 blocks a tick. A client walking 1.5 times faster is flagged on every move.

[anticheat.speed]   # every key optional
setback = 5
alert = 15
kick = 60
decay = 2
tolerance = 0.05

Cost (measured)

60 bots walking on the ground in survival, every move judged by both speed and ground: tools/server_bench.py --servers horizon --bots 60 --behaviour walk --ground, Mac mini, 120 s after a 30 s warm-up, MSPT from /tick query, main / off / on interleaved twice:

server MSPT avg (run 1 / run 2) P95 P99 flags
main (073afd484) 4.66 / 4.62 5.33 / 5.19 6.62 / 5.83 –
this branch, anticheat off 4.74 / 4.44 5.32 / 4.95 6.26 / 5.39 0 / 0
this branch, anticheat on 4.60 / 4.78 5.15 / 5.46 6.15 / 6.39 0 / 0

Within noise: a few multiplications per move, and one block read for the friction. None of the 60 legit bots was flagged; the server wrote no anticheat log at all.

Originality

Written from vanilla 26.3's movement code (above) and the public description of what speed hacks do. No other anticheat's code or docs were read.

Tests

  • horizon-anticheat unit tests: vanilla sprinting from a stand, a sprint jump, the air after it, 200 ticks on blue ice, two ticks in one move and knockback all pass; a 1.5× walker is flagged on 39 of 40 moves; ramping up to it doesn't help.
  • tools/anticheat_e2e.py --check speed (new), a real survival dedicated server: a bot walking 1.5× faster than sprinting is flagged (85 times in 30 s), sent back and kicked; 5 bots walking with vanilla's acceleration are never flagged by any check. ground passes again with the walkers now accelerating as vanilla's.
  • horizon-bots: on the ground (--ground), walking now accelerates as vanilla's does (it kept a constant 5.6 blocks a second from a stand); --speed F is the cheat.

pr_ready (tools/pr_ready.py --quick on ludovics-mac-mini, against origin/main at e825d36af, 9 min 29 s)

Check Result
Scope ✅ 12 files, +407 −12
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 481 passed (1 min 12 s)
rustfmt ✅ (9 s)
clippy ✅ (1 min 24 s)
tests: horizon-anticheat, horizon-bots, horizon-client ✅ 1214 passed (6 min 11 s)
doc tests ✅ 0 passed (2 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 ➖ 33 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 21 more
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

Harnesses (tools/parity.py --changed origin/main, Mac mini, on the stacked branch before the rebase onto main): 34 of 35 pass. lunge_motion fails the same way on main (3a5ac7ffe): its vanilla transcript's vertical motion differs at a different step from run to run, and it's an integrated-server probe where the anticheat never runs.
tools/anticheat_e2e.py on this head (rebased on main with #4675): off, timer, ground and speed pass.

🤖 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/4735 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/anticheat-speed` --- ### 📝 Commits (1) - [`5be58cf`](https://github.com/horizon-rust/horizon/commit/5be58cf46b901a13d3f98ed7c20bf78b8b038b5f) Anticheat: the speed check ### 📊 Changes **12 files changed** (+407 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-anticheat/src/lib.rs` (+12 -0) ➕ `crates/horizon-anticheat/src/speed.rs` (+217 -0) 📝 `crates/horizon-bots/src/main.rs` (+17 -2) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+1 -4) 📝 `crates/horizon-client/src/game/lan_mobs.rs` (+1 -5) 📝 `crates/horizon-client/src/game/lan_particles.rs` (+1 -0) 📝 `crates/horizon-client/src/lan/anticheat.rs` (+84 -0) 📝 `crates/horizon-client/src/lan/chunks.rs` (+22 -0) 📝 `crates/horizon-client/src/lan/guest.rs` (+12 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+8 -0) 📝 `docs/anticheat.md` (+1 -0) 📝 `tools/anticheat_e2e.py` (+31 -1) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What and why The dedicated server's anticheat gets a **`speed`** check: moving sideways faster than vanilla allows (speed hacks). **Off unless `[anticheat]` is in `server.toml`.** Vanilla only refuses moves of more than 10 blocks a tick ("moved too quickly"), so anything slower passes. Vanilla's own movement code is the limit (`LivingEntity.travelInAir`, `Player.getFlyingSpeed`, `jumpFromGround`), taken at its largest (`crates/horizon-anticheat/src/speed.rs`, unit-tested). A move is at most: - the previous move (at most what the rule allowed then) times the friction it carries into this tick: the block's friction × 0.91 if that tick started on the ground, else 0.91; - plus this tick's acceleration: the movement speed attribute (effects included) × 1.3 (as if sprinting) × 0.216 / friction³ on the ground, 0.026 in the air; - plus 0.2 if the tick starts on the ground and goes up (a sprint jump); - or more, if the server pushed the player: the largest push from `SetEntityMotion` and explosions, fading over about a second for the round trip; - counted per client tick: the `ClientTickEnd`s since the last move, since a still client skips moves. Ice (up to blue ice's 0.989) and slime (0.8) have their own friction, read from a new flag on the chunk encoder's block states. On top comes `tolerance`, 0.05 blocks. Not judged: water and lava (currents, Depth Strider, Dolphin's Grace), gliding, Riptide, creative and spectators, vehicles, and the move after a teleport. On stone, the limit levels off at vanilla's sprint, 0.286 blocks a tick. A client walking 1.5 times faster is flagged on every move. ```toml [anticheat.speed] # every key optional setback = 5 alert = 15 kick = 60 decay = 2 tolerance = 0.05 ``` ## Cost (measured) 60 bots walking on the ground in survival, every move judged by both `speed` and `ground`: `tools/server_bench.py --servers horizon --bots 60 --behaviour walk --ground`, Mac mini, 120 s after a 30 s warm-up, MSPT from `/tick query`, main / off / on interleaved twice: | server | MSPT avg (run 1 / run 2) | P95 | P99 | flags | |---|---|---|---|---| | main (073afd484) | 4.66 / 4.62 | 5.33 / 5.19 | 6.62 / 5.83 | – | | this branch, anticheat off | 4.74 / 4.44 | 5.32 / 4.95 | 6.26 / 5.39 | 0 / 0 | | this branch, anticheat on | 4.60 / 4.78 | 5.15 / 5.46 | 6.15 / 6.39 | 0 / 0 | Within noise: a few multiplications per move, and one block read for the friction. None of the 60 legit bots was flagged; the server wrote no anticheat log at all. ## Originality Written from vanilla 26.3's movement code (above) and the public description of what speed hacks do. No other anticheat's code or docs were read. ## Tests - `horizon-anticheat` unit tests: vanilla sprinting from a stand, a sprint jump, the air after it, 200 ticks on blue ice, two ticks in one move and knockback all pass; a 1.5× walker is flagged on 39 of 40 moves; ramping up to it doesn't help. - `tools/anticheat_e2e.py --check speed` (new), a real survival dedicated server: a bot walking 1.5× faster than sprinting is flagged (85 times in 30 s), sent back and kicked; 5 bots walking with vanilla's acceleration are never flagged by any check. `ground` passes again with the walkers now accelerating as vanilla's. - horizon-bots: on the ground (`--ground`), walking now accelerates as vanilla's does (it kept a constant 5.6 blocks a second from a stand); `--speed F` is the cheat. **pr_ready** (`tools/pr_ready.py --quick` on ludovics-mac-mini, against origin/main at e825d36af, 9 min 29 s) | Check | Result | | --- | --- | | Scope | ✅ 12 files, +407 −12 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 481 passed (1 min 12 s) | | rustfmt | ✅ (9 s) | | clippy | ✅ (1 min 24 s) | | tests: horizon-anticheat, horizon-bots, horizon-client | ✅ 1214 passed (6 min 11 s) | | doc tests | ✅ 0 passed (2 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 | ➖ 33 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 21 more | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | **Harnesses** (`tools/parity.py --changed origin/main`, Mac mini, on the stacked branch before the rebase onto main): 34 of 35 pass. `lunge_motion` fails the same way on main (3a5ac7ffe): its vanilla transcript's vertical motion differs at a different step from run to run, and it's an integrated-server probe where the anticheat never runs. `tools/anticheat_e2e.py` on this head (rebased on main with #4675): off, timer, ground and speed pass. 🤖 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:15:12 +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#5817
No description provided.