[PR #6381] [MERGED] Push the shield before the hit that it only partly blocked #6835

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

📋 Pull Request Information

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

Base: main ← Head: fix/shield-push-order


📝 Commits (1)

  • c30dc0f Push the shield before the hit that it only partly blocked

📊 Changes

1 file changed (+14 additions, -6 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+14 -6)

📄 Description

For a melee hit a blocks_attacks item only partly blocks, vanilla makes two pushes on the
defender, and LivingEntity.knockback halves the old horizontal motion before adding the new
one, so their order decides the result:

  1. hurtServer calls applyItemBlocking first, whose blockUsingItem reaches
    blockedByItem: defender.knockback(0.5, defender - attacker) when the hit was not fully
    blocked.
  2. Later the same method runs dealDefaultKnockback: knockback(0.4, attacker - defender).

Horizon had the same two pushes in the opposite order: hurt_player_from applied
knock_back_player(0.4, ...) inside the hurt, and only afterwards called after_block, where
the shield's blocked_by_attacker pushed with 0.5. A half-blocked defender therefore ended up
moving toward the attacker instead of away.

The hit's push is now held until after after_block has run, which puts the shield's push first
as vanilla does. Nothing else about either push changed: same magnitudes, same conditions, same
knockback resistance and native hook.

Proven: compile-checked with cargo check -q -p horizon-client --lib --bins on the build VM.

Not proven: no test. Reproducing it needs a running server and two clients;
tools/test_server_knockback_parity.py already compares ClientboundSetEntityMotionPacket for
both sides and is where the issue's two cases belong. The expected numbers from the report are
0.14997 0.39999 0 for a sword hit against a shield with damage_reductions: [{base:0,factor:0.5}] and 0.08191 0.31362 0 for a zombie's hit.

One thing that changes with the order: hurt_log's recorded knockback is taken after both
pushes now, so it is the velocity the defender actually leaves with - the same value vanilla
reports for that field.


🔄 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/6381 **Author:** [@MSedgeMC](https://github.com/MSedgeMC) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/shield-push-order` --- ### 📝 Commits (1) - [`c30dc0f`](https://github.com/horizon-rust/horizon/commit/c30dc0febf9683f57021b1f4ee3a01746d905f6f) Push the shield before the hit that it only partly blocked ### 📊 Changes **1 file changed** (+14 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+14 -6) </details> ### 📄 Description For a melee hit a `blocks_attacks` item only partly blocks, vanilla makes two pushes on the defender, and `LivingEntity.knockback` halves the old horizontal motion before adding the new one, so their order decides the result: 1. `hurtServer` calls `applyItemBlocking` first, whose `blockUsingItem` reaches `blockedByItem`: `defender.knockback(0.5, defender - attacker)` when the hit was not fully blocked. 2. Later the same method runs `dealDefaultKnockback`: `knockback(0.4, attacker - defender)`. Horizon had the same two pushes in the opposite order: `hurt_player_from` applied `knock_back_player(0.4, ...)` inside the hurt, and only afterwards called `after_block`, where the shield's `blocked_by_attacker` pushed with 0.5. A half-blocked defender therefore ended up moving toward the attacker instead of away. The hit's push is now held until after `after_block` has run, which puts the shield's push first as vanilla does. Nothing else about either push changed: same magnitudes, same conditions, same knockback resistance and native hook. **Proven:** compile-checked with `cargo check -q -p horizon-client --lib --bins` on the build VM. **Not proven:** no test. Reproducing it needs a running server and two clients; `tools/test_server_knockback_parity.py` already compares `ClientboundSetEntityMotionPacket` for both sides and is where the issue's two cases belong. The expected numbers from the report are `0.14997 0.39999 0` for a sword hit against a shield with `damage_reductions: [{base:0,factor:0.5}]` and `0.08191 0.31362 0` for a zombie's hit. One thing that changes with the order: `hurt_log`'s recorded knockback is taken after both pushes now, so it is the velocity the defender actually leaves with - the same value vanilla reports for that field. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:27:45 +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#6835
No description provided.