[PR #3251] [MERGED] Apply the attacker's 0.6 speed cut after a knockback hit on another p… #4864

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3251
Author: @1038april
Created: 10/28/2026
Status: ✅ Merged
Merged: 10/30/2026
Merged by: @ludovic111

Base: main ← Head: fix/remote-sprint-hit-slowdown


📝 Commits (4)

  • 2228a74 Apply the attacker's 0.6 speed cut after a knockback hit on another player
  • 0e4c964 Keep Player.attack's no-damage guard before the attacker's sprint-hit cut
  • 6106665 Mirror the attacking client's Player.attack, not the server's, and add its harness
  • 5a7cfb4 lan_e2e: check that a sprinting guest's hit slows it

📊 Changes

8 files changed (+520 additions, -6 deletions)

View changed files

📝 crates/horizon-client/examples/probe/main.rs (+2 -0)
➕ crates/horizon-client/examples/probe/remote_attack_probe.rs (+52 -0)
📝 crates/horizon-client/src/attack_strength.rs (+87 -0)
📝 crates/horizon-client/src/game/enchant_effects.rs (+7 -6)
📝 crates/horizon-client/src/game/remote.rs (+62 -0)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/VanillaRemoteAttackOracle.java (+170 -0)
📝 tools/lan_e2e.py (+62 -0)
➕ tools/test_remote_attack_parity.py (+78 -0)

📄 Description

What and why

On a server, sprint-hitting a nearby player makes the attacker jitter and snap back (seen on Hypixel).

MultiPlayerGameMode.attack runs Player.attack on the attacking client as well as sending the packet. For a mob, the client's hurtOrSimulate fails (Entity.hurtClient), so the hit has no attacker side, which is what stop_sprint_after_extra_knockback's comment describes. But RemotePlayer.hurtClient is true: a hit with extra knockback on another player runs the attacker's side of causeExtraKnockback on the client too, cutting horizontal speed to 0.6 and stopping the sprint. Horizon's remote attack path only sent the packet, so after such a hit the client kept its speed while the server's player slowed, and the server corrected the position.

The fix adds remote_player_attack, called after the attack packet when the target is a listed player. It mirrors the attacking client's Player.attack, not the server's: the client's own ATTACK_DAMAGE (or a riptide spin's damage) and ATTACK_KNOCKBACK decide, because held items, effects and enchantments don't count on a client. If the hit has knockback, it multiplies the local player's horizontal velocity by 0.6 and stops the sprint. Hits on mobs are unchanged.

The attack strength it uses is hand_strength.scale(0.5, speed), not attack_strength_scale(): attack_ticks only advances in the local world (tick_creatures), so on a server it stays at 0. The speed is the player's synced minecraft:attack_speed attribute when the server sent one, else main_hand_attack_speed(); servers like Hypixel raise it for 1.8-style combat, and main_hand_attack_speed() ignores the synced value. (The HUD's attack indicator reads main_hand_attack_speed() too and may be off on such servers; not touched here.)

Tested by hand on Hypixel with an earlier version of the change on v0.2.93 (swapped into the launcher's install): sprint-hitting a nearby player no longer jitters. The first version, which used attack_strength_scale(), didn't fix it, which is how the two points above were found.

Vanilla reference

  • MultiPlayerGameMode.attack → Player.attack → causeExtraKnockback (attacker: setDeltaMovement(getDeltaMovement().multiply(0.6, 1.0, 0.6)), setSprinting(false)).
  • Entity.hurtOrSimulate / hurtClient, and RemotePlayer.hurtClient returning true.
  • Player.getAttackStrengthScale(0.5) with the ATTACK_SPEED attribute.
  • Checked against the 26.3 jars: RemotePlayer.hurtClient returns true.
  • Harness: tools/test_remote_attack_parity.py (VanillaRemoteAttackOracle, remote_attack_probe): 51,840 cases identical.

Self-check

python tools/pr_ready.py --quick at 61066655f's changes, on Windows with the game files:

Check Result
Scope ✅ 7 files, +458 −6
Cargo.lock ✅ unchanged
Public tree ✅
rustfmt ✅
clippy ✅
Python tests ❌ 3 fail
tests: horizon-client ❌ 1121 passed, 1 failed
Parity test_remote_attack_parity passes; the other harnesses not run

The failures also occur without this commit on the same Windows machine: save::tests::session_lock_is_exclusive, test_port_publish (2) and test_roadmap. cargo test -p horizon-client --bins passes.

Independent of #3221, which touches a different function in the same file.


🔄 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/3251 **Author:** [@1038april](https://github.com/1038april) **Created:** 10/28/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/remote-sprint-hit-slowdown` --- ### 📝 Commits (4) - [`2228a74`](https://github.com/horizon-rust/horizon/commit/2228a7456e52ae6c4b69e38c302753db4668a69b) Apply the attacker's 0.6 speed cut after a knockback hit on another player - [`0e4c964`](https://github.com/horizon-rust/horizon/commit/0e4c964d0ac2bd41e1d9e4a698315d0bef95635a) Keep Player.attack's no-damage guard before the attacker's sprint-hit cut - [`6106665`](https://github.com/horizon-rust/horizon/commit/61066655feda64fd5ddba4ef64c8bb8a3926acb2) Mirror the attacking client's Player.attack, not the server's, and add its harness - [`5a7cfb4`](https://github.com/horizon-rust/horizon/commit/5a7cfb443fd0555427294931ae328fa28bbafcff) lan_e2e: check that a sprinting guest's hit slows it ### 📊 Changes **8 files changed** (+520 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/examples/probe/main.rs` (+2 -0) ➕ `crates/horizon-client/examples/probe/remote_attack_probe.rs` (+52 -0) 📝 `crates/horizon-client/src/attack_strength.rs` (+87 -0) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+7 -6) 📝 `crates/horizon-client/src/game/remote.rs` (+62 -0) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/VanillaRemoteAttackOracle.java` (+170 -0) 📝 `tools/lan_e2e.py` (+62 -0) ➕ `tools/test_remote_attack_parity.py` (+78 -0) </details> ### 📄 Description ## What and why On a server, sprint-hitting a nearby player makes the attacker jitter and snap back (seen on Hypixel). `MultiPlayerGameMode.attack` runs `Player.attack` on the attacking client as well as sending the packet. For a mob, the client's `hurtOrSimulate` fails (`Entity.hurtClient`), so the hit has no attacker side, which is what `stop_sprint_after_extra_knockback`'s comment describes. But `RemotePlayer.hurtClient` is true: a hit with extra knockback on another *player* runs the attacker's side of `causeExtraKnockback` on the client too, cutting horizontal speed to 0.6 and stopping the sprint. Horizon's remote attack path only sent the packet, so after such a hit the client kept its speed while the server's player slowed, and the server corrected the position. The fix adds `remote_player_attack`, called after the attack packet when the target is a listed player. It mirrors the attacking client's `Player.attack`, not the server's: the client's own ATTACK_DAMAGE (or a riptide spin's damage) and ATTACK_KNOCKBACK decide, because held items, effects and enchantments don't count on a client. If the hit has knockback, it multiplies the local player's horizontal velocity by 0.6 and stops the sprint. Hits on mobs are unchanged. The attack strength it uses is `hand_strength.scale(0.5, speed)`, not `attack_strength_scale()`: `attack_ticks` only advances in the local world (`tick_creatures`), so on a server it stays at 0. The speed is the player's synced `minecraft:attack_speed` attribute when the server sent one, else `main_hand_attack_speed()`; servers like Hypixel raise it for 1.8-style combat, and `main_hand_attack_speed()` ignores the synced value. (The HUD's attack indicator reads `main_hand_attack_speed()` too and may be off on such servers; not touched here.) Tested by hand on Hypixel with an earlier version of the change on v0.2.93 (swapped into the launcher's install): sprint-hitting a nearby player no longer jitters. The first version, which used `attack_strength_scale()`, didn't fix it, which is how the two points above were found. ## Vanilla reference - `MultiPlayerGameMode.attack` → `Player.attack` → `causeExtraKnockback` (attacker: `setDeltaMovement(getDeltaMovement().multiply(0.6, 1.0, 0.6))`, `setSprinting(false)`). - `Entity.hurtOrSimulate` / `hurtClient`, and `RemotePlayer.hurtClient` returning true. - `Player.getAttackStrengthScale(0.5)` with the `ATTACK_SPEED` attribute. - Checked against the 26.3 jars: `RemotePlayer.hurtClient` returns true. - Harness: `tools/test_remote_attack_parity.py` (`VanillaRemoteAttackOracle`, `remote_attack_probe`): 51,840 cases identical. ## Self-check `python tools/pr_ready.py --quick` at 61066655f's changes, on Windows with the game files: | Check | Result | | --- | --- | | Scope | ✅ 7 files, +458 −6 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | clippy | ✅ | | Python tests | ❌ 3 fail | | tests: horizon-client | ❌ 1121 passed, 1 failed | | Parity | `test_remote_attack_parity` passes; the other harnesses not run | The failures also occur without this commit on the same Windows machine: `save::tests::session_lock_is_exclusive`, `test_port_publish` (2) and `test_roadmap`. `cargo test -p horizon-client --bins` passes. Independent of #3221, which touches a different function in the same file. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:08:29 +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#4864
No description provided.