[PR #1106] [MERGED] Combat: sprint knockback and knockback along the attacker's yaw; vanilla knockback on players #3053

Closed
opened 2026-11-02 16:01:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/attack-knockback


📝 Commits (1)

  • 9d9f259 Combat: sprint and yaw knockback (Player.causeExtraKnockback); vanilla knockback on the player

📊 Changes

4 files changed (+123 additions, -47 deletions)

View changed files

📝 crates/horizon-client/src/game.rs (+10 -0)
📝 crates/horizon-client/src/game/creatures.rs (+31 -7)
📝 crates/horizon-client/src/game/enchant_effects.rs (+45 -30)
📝 crates/horizon-client/src/game/lan_pvp.rs (+37 -10)

📄 Description

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

Fixes #504. Reported by Online5277: thanks!

What

Melee knockback now follows vanilla's Player.attack, for hits on mobs and on players (LAN):

  • Sprint knockback: a sprinting full-strength hit adds 0.5 knockback (it added nothing) and plays entity.player.attack.knockback.
  • Knockback displacement: that extra knockback (causeExtraKnockback: the Knockback enchantment, halved, plus the sprint bonus) pushes the target along the attacker's yaw (sin yRot, -cos yRot), not away from the attacker, so turning while hitting steers where the target flies. Players hit by players got none of it.
  • After that knockback the attacker stops sprinting (the server's flag reaching the attacking client; the server's 0.6 speed cut never reaches the client, whose own Player.attack simulates no hurt).
  • The knockback a player takes (dealDefaultKnockback, 0.4) now goes through LivingEntity.knockback: it reads the player's knockback resistance (netherite armor) and only lifts a player standing on the ground. Before, every hit threw an airborne player up again.

How

game/enchant_effects.rs (extra_knockback, its direction, the attacker's sprint stop), game.rs (hits on mobs), game/lan_pvp.rs (hits on players), game/creatures.rs (knock_back_player).

Not covered: a LAN guest's own sprint flag after its knockback hit stays the guest client's (the hub doesn't clear it).

Proof

Self-check on one integration commit holding the seven B4 branches (#1049 #1050 #1046 #1056 #505 #504 #1097), on origin/main caeffffb, on the Mac mini:

cargo fmt --all --check                                                   ok
set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings    exit 0
cargo test -p horizon-client -p horizon-world                             all passed, 0 failed (horizon-client lib 959, horizon-world lib 152, ...)

tools/parity.py --changed origin/main (selects 304 of 326 harnesses: the branches touch game.rs): running on the integration commit; the result follows in a comment.

Needs Ludovic

Nothing.

🤖 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/1106 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/21/2026 **Status:** ✅ Merged **Merged:** 10/21/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/attack-knockback` --- ### 📝 Commits (1) - [`9d9f259`](https://github.com/horizon-rust/horizon/commit/9d9f259f94a5a9482e3ea397bfc4a13d9a6e137b) Combat: sprint and yaw knockback (Player.causeExtraKnockback); vanilla knockback on the player ### 📊 Changes **4 files changed** (+123 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game.rs` (+10 -0) 📝 `crates/horizon-client/src/game/creatures.rs` (+31 -7) 📝 `crates/horizon-client/src/game/enchant_effects.rs` (+45 -30) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+37 -10) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Fixes #504. Reported by **Online5277**: thanks! ## What Melee knockback now follows vanilla's `Player.attack`, for hits on mobs and on players (LAN): - **Sprint knockback**: a sprinting full-strength hit adds 0.5 knockback (it added nothing) and plays `entity.player.attack.knockback`. - **Knockback displacement**: that extra knockback (`causeExtraKnockback`: the Knockback enchantment, halved, plus the sprint bonus) pushes the target along the attacker's yaw (`sin yRot, -cos yRot`), not away from the attacker, so turning while hitting steers where the target flies. Players hit by players got none of it. - After that knockback the attacker stops sprinting (the server's flag reaching the attacking client; the server's 0.6 speed cut never reaches the client, whose own `Player.attack` simulates no hurt). - The knockback a player takes (`dealDefaultKnockback`, 0.4) now goes through `LivingEntity.knockback`: it reads the player's knockback resistance (netherite armor) and only lifts a player standing on the ground. Before, every hit threw an airborne player up again. ## How `game/enchant_effects.rs` (`extra_knockback`, its direction, the attacker's sprint stop), `game.rs` (hits on mobs), `game/lan_pvp.rs` (hits on players), `game/creatures.rs` (`knock_back_player`). Not covered: a LAN guest's own sprint flag after its knockback hit stays the guest client's (the hub doesn't clear it). ## Proof Self-check on one integration commit holding the seven B4 branches (#1049 #1050 #1046 #1056 #505 #504 #1097), on origin/main `caeffffb`, on the Mac mini: ``` cargo fmt --all --check ok set -o pipefail; cargo clippy --workspace --all-targets -- -D warnings exit 0 cargo test -p horizon-client -p horizon-world all passed, 0 failed (horizon-client lib 959, horizon-world lib 152, ...) ``` `tools/parity.py --changed origin/main` (selects 304 of 326 harnesses: the branches touch `game.rs`): running on the integration commit; the result follows in a comment. ## Needs Ludovic Nothing. 🤖 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-02 16:01:07 +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#3053
No description provided.