[PR #1548] [MERGED] Travel a guest's server-side velocity, and send hurts after it #3575

Closed
opened 2026-11-03 04:10:33 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

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

Base: main ← Head: fix/kb1-server-velocity


📝 Commits (2)

  • 50aee22 Add a knockback harness: a dedicated server against vanilla's
  • 7c83fbb Travel a guest's server-side velocity, and send hurts after it

📊 Changes

7 files changed (+1013 additions, -50 deletions)

View changed files

📝 crates/horizon-client/src/game/lan_actions.rs (+27 -5)
📝 crates/horizon-client/src/game/lan_mobs.rs (+38 -5)
📝 crates/horizon-client/src/game/lan_pvp.rs (+1 -1)
📝 crates/horizon-client/src/motion.rs (+128 -39)
➕ mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java (+444 -0)
📝 tools/lan_e2e.py (+47 -0)
➕ tools/test_server_knockback_parity.py (+328 -0)

📄 Description

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

Stacked on #1545 (merge that first).

What

A guest's knockback is now worked out the way vanilla's server works it out. This covers a LAN guest, a player on a dedicated server, and, on the server thread (the single player default since #1514), the window itself.

  • MotionWorld::server_travel: Player.travel with no input, keeping only the velocity it leaves. The client's next move still places the player. While it runs, the server copy checks no fall damage on its own moves (isLocalInstanceAuthoritative is false for a player on the server).
  • guest_server_tick runs it last in the guest's tick. Then, if a hurt marked the velocity since the last tick (Entity.markHurt, health.sync_velocity), it sends ClientboundSetEntityMotionPacket with the travelled velocity (ServerEntity.sendChanges).
  • guest_hit_by leaves a marked velocity to that send. A push with no hurt still goes out at once, as before.
  • guest_struck_by, for a player's melee hit (Player.causeExtraKnockback): if the hurt marked the velocity, it sends at once, then puts the server copy back to the velocity it had before the hit.
  • lan_e2e knockback: the host hits the guest three times, then the guest hits the host three times. Each hit must slide the victim vanilla's 1.989 blocks.

Why

vanilla's server simulates players too (MoveSimulationType.AUTHORITATIVE_SIDE_AND_SERVER). A standing ServerPlayer's velocity settles at (0, -0.0784, 0), and knockback starts from it: LivingEntity.knockback halves the old velocity and adds the push.

Horizon never travelled the guest's server copy, so its velocity kept whatever the last hit or water push left. Each hit started from the previous one, and was sent before that tick's friction. Through a vanilla client, against vanilla's server:

case vanilla main this PR
plain hit 0.400 / 0.361 0.400 / 0.400, then 0.795 / 0.400 0.400 / 0.361
two hits a second apart 0.400 / 0.361 twice 0.795, 0.797 0.400 / 0.361 twice
netherite (knockback resistance) 0.240 / 0.201 0.790 / 0.400 0.240 / 0.201
Knockback II 1.200 / 0.400 1.400 / 0.400 1.200 / 0.400
zombie's hit, twice -0.218 / 0.275 twice 0.031 / 0.400, -0.384 / 0.400 -0.218 / 0.275 twice
stronger hit in the hurt cooldown one packet two one

(x / y of the victim's motion packet, in blocks a tick.)

How tested

$ cargo fmt --all -- --check                                   # clean
$ cargo clippy --workspace --all-targets -- -D warnings        # clean (on each branch alone and on the integration commit of all six)
$ cargo test -p horizon-client                                 # 1205 passed, 0 failed (integration commit)
  (new: motion::tests::server_travel_moves_only_the_velocity)
$ python3 tools/test_server_knockback_parity.py
server knockback: 14 of 21 cases identical (KNOWN: the 7 the next PRs fix)
$ python3 tools/parity.py --changed origin/main                # 107 passed, 0 failed (integration commit of all six)
$ python3 tools/lan_e2e.py --check knockback [--server-thread]  # two real Horizon clients, blocks slid per hit
  main, in-frame:      host hits guest [2.064, 1.03, 1.548]   guest hits host [1.989, 1.989, 1.989]   FAIL
  main, server thread: host hits guest [2.064, 1.03, 1.548]   guest hits host [2.064, 1.03, 1.548]   FAIL
  this PR, both modes: host hits guest [1.989, 1.989, 1.989]  guest hits host [1.989, 1.989, 1.989]  PASS
  (1.989 is vanilla's slide for a plain hit on a standing player; the attacker switches sides each hit)

KNOWN keeps the cases the next PRs fix: the guest's own sprint flag, the extra knockback's yaw, and the mace smash on a player.

Not changed here

The in-frame host (--in-frame) is unchanged. Its knockback starts from its own client velocity, which matches vanilla while it stands. A host who is moving when hit is pushed differently: vanilla starts from the server copy, which has almost no horizontal speed. That is left for a follow-up.

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/1548 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/24/2026 **Status:** ✅ Merged **Merged:** 10/24/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/kb1-server-velocity` --- ### 📝 Commits (2) - [`50aee22`](https://github.com/horizon-rust/horizon/commit/50aee229966766e850131d5edf6fcd2cd0c9cfdb) Add a knockback harness: a dedicated server against vanilla's - [`7c83fbb`](https://github.com/horizon-rust/horizon/commit/7c83fbb6df401eb4db6a60289cf26e70b55d7c48) Travel a guest's server-side velocity, and send hurts after it ### 📊 Changes **7 files changed** (+1013 additions, -50 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/lan_actions.rs` (+27 -5) 📝 `crates/horizon-client/src/game/lan_mobs.rs` (+38 -5) 📝 `crates/horizon-client/src/game/lan_pvp.rs` (+1 -1) 📝 `crates/horizon-client/src/motion.rs` (+128 -39) ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java` (+444 -0) 📝 `tools/lan_e2e.py` (+47 -0) ➕ `tools/test_server_knockback_parity.py` (+328 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. Stacked on #1545 (merge that first). ## What A guest's knockback is now worked out the way vanilla's server works it out. This covers a LAN guest, a player on a dedicated server, and, on the server thread (the single player default since #1514), the window itself. - **`MotionWorld::server_travel`**: `Player.travel` with no input, keeping only the velocity it leaves. The client's next move still places the player. While it runs, the server copy checks no fall damage on its own moves (`isLocalInstanceAuthoritative` is false for a player on the server). - **`guest_server_tick`** runs it last in the guest's tick. Then, if a hurt marked the velocity since the last tick (`Entity.markHurt`, `health.sync_velocity`), it sends `ClientboundSetEntityMotionPacket` with the travelled velocity (`ServerEntity.sendChanges`). - **`guest_hit_by`** leaves a marked velocity to that send. A push with no hurt still goes out at once, as before. - **`guest_struck_by`**, for a player's melee hit (`Player.causeExtraKnockback`): if the hurt marked the velocity, it sends at once, then puts the server copy back to the velocity it had before the hit. - **lan_e2e `knockback`**: the host hits the guest three times, then the guest hits the host three times. Each hit must slide the victim vanilla's 1.989 blocks. ## Why vanilla's server simulates players too (`MoveSimulationType.AUTHORITATIVE_SIDE_AND_SERVER`). A standing ServerPlayer's velocity settles at (0, -0.0784, 0), and knockback starts from it: `LivingEntity.knockback` halves the old velocity and adds the push. Horizon never travelled the guest's server copy, so its velocity kept whatever the last hit or water push left. Each hit started from the previous one, and was sent before that tick's friction. Through a vanilla client, against vanilla's server: | case | vanilla | main | this PR | | --- | --- | --- | --- | | plain hit | 0.400 / 0.361 | 0.400 / 0.400, then 0.795 / 0.400 | 0.400 / 0.361 | | two hits a second apart | 0.400 / 0.361 twice | 0.795, 0.797 | 0.400 / 0.361 twice | | netherite (knockback resistance) | 0.240 / 0.201 | 0.790 / 0.400 | 0.240 / 0.201 | | Knockback II | 1.200 / 0.400 | 1.400 / 0.400 | 1.200 / 0.400 | | zombie's hit, twice | -0.218 / 0.275 twice | 0.031 / 0.400, -0.384 / 0.400 | -0.218 / 0.275 twice | | stronger hit in the hurt cooldown | one packet | two | one | (x / y of the victim's motion packet, in blocks a tick.) ## How tested ``` $ cargo fmt --all -- --check # clean $ cargo clippy --workspace --all-targets -- -D warnings # clean (on each branch alone and on the integration commit of all six) $ cargo test -p horizon-client # 1205 passed, 0 failed (integration commit) (new: motion::tests::server_travel_moves_only_the_velocity) $ python3 tools/test_server_knockback_parity.py server knockback: 14 of 21 cases identical (KNOWN: the 7 the next PRs fix) $ python3 tools/parity.py --changed origin/main # 107 passed, 0 failed (integration commit of all six) $ python3 tools/lan_e2e.py --check knockback [--server-thread] # two real Horizon clients, blocks slid per hit main, in-frame: host hits guest [2.064, 1.03, 1.548] guest hits host [1.989, 1.989, 1.989] FAIL main, server thread: host hits guest [2.064, 1.03, 1.548] guest hits host [2.064, 1.03, 1.548] FAIL this PR, both modes: host hits guest [1.989, 1.989, 1.989] guest hits host [1.989, 1.989, 1.989] PASS (1.989 is vanilla's slide for a plain hit on a standing player; the attacker switches sides each hit) ``` `KNOWN` keeps the cases the next PRs fix: the guest's own sprint flag, the extra knockback's yaw, and the mace smash on a player. ## Not changed here The in-frame host (`--in-frame`) is unchanged. Its knockback starts from its own client velocity, which matches vanilla while it stands. A host who is moving when hit is pushed differently: vanilla starts from the server copy, which has almost no horizontal speed. That is left for a follow-up. ## 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-03 04:10:33 +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#3575
No description provided.