[PR #1545] [MERGED] Add a knockback harness: a dedicated server against vanilla's #3574

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

📋 Pull Request Information

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

Base: main ← Head: fix/kb1-knockback-harness


📝 Commits (1)

  • 50aee22 Add a knockback harness: a dedicated server against vanilla's

📊 Changes

2 files changed (+781 additions, -0 deletions)

View changed files

➕ mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java (+444 -0)
➕ tools/test_server_knockback_parity.py (+337 -0)

📄 Description

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

What

tools/test_server_knockback_parity.py: knockback on a dedicated server, against vanilla 26.3's, as two vanilla-codec players (KnockbackClient, a new Java oracle) receive it. Both servers serve a copy of one flat world vanilla generated.

  • Alice hits a cow and a zombie: plain, sprinting, Knockback II, critical, and a mob in the air. The game is frozen around the hit and stepped a tick at a time. The mob's Motion after the hit, and its Pos and Motion over the next 20 ticks, are compared to 1e-9.
  • Alice hits Bob: the same hits, plus a raised shield, netherite, two hits a second apart, two sprinting hits, a mace smash, and a stronger hit inside the hurt cooldown. Compared: Bob's own ClientboundSetEntityMotionPacket, Alice's motion packets, and her sprint flag as the server sends it.
  • A zombie hits Bob twice (a real AI attack, awaited): his motion packets.

Why

A Discord report (nuuhlusinhas) says knockback is off in LAN, on servers and in single player. This harness measures it and holds the fixes in place. Since #1514 single player runs on the server thread, where the window is a guest of the same code a LAN guest or a dedicated server's player goes through.

Result on main

7 of 21 cases match. KNOWN lists the other 14 and their causes. The PRs stacked on this one fix them and take them out:

  • Server-side velocity (next PR): a guest's velocity on the server never travels, so knockback adds up from hit to hit, and a mob's hit is sent before the friction of its tick.
    • Plain hit: 0.400 / 0.361 in vanilla; on main 0.400 / 0.400 on a fresh body, and 0.795 / 0.400 once earlier hits have added up.
    • Netherite: 0.240 / 0.201 in vanilla, 0.790 / 0.400 on main.
    • Zombie: -0.218 / 0.275 in vanilla, 0.031 / 0.400 then -0.384 / 0.400 on main.
  • Sprint flag: the server never sends a guest its own sprint flag, so a sprinting hit doesn't stop the attacker's sprint.
  • Yaw: the extra knockback's direction uses f32 sin/cos, not Mth's table, which leaves a z of -2e-8 per block.
  • Mace (not fixed here, still in KNOWN at the top of the stack): a smash on a player runs none of MaceItem.hurtEnemy. The attacker gets no motion packet and keeps falling.

How tested

$ python3 tools/test_server_knockback_parity.py      # on this branch (main + the harness)
server knockback: 7 of 21 cases identical
$ python3 tools/test_server_knockback_parity.py      # top of the stack (velocity + sprint + yaw)
server knockback: 20 of 21 cases identical

The oracle compiles with the same javac --release 25 -proc:none line as the other harness clients. Nothing player-facing: skip-release.

🤖 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/1545 **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-knockback-harness` --- ### 📝 Commits (1) - [`50aee22`](https://github.com/horizon-rust/horizon/commit/50aee229966766e850131d5edf6fcd2cd0c9cfdb) Add a knockback harness: a dedicated server against vanilla's ### 📊 Changes **2 files changed** (+781 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java` (+444 -0) ➕ `tools/test_server_knockback_parity.py` (+337 -0) </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What `tools/test_server_knockback_parity.py`: knockback on a dedicated server, against vanilla 26.3's, as two vanilla-codec players (`KnockbackClient`, a new Java oracle) receive it. Both servers serve a copy of one flat world vanilla generated. - **Alice hits a cow and a zombie**: plain, sprinting, Knockback II, critical, and a mob in the air. The game is frozen around the hit and stepped a tick at a time. The mob's Motion after the hit, and its Pos and Motion over the next 20 ticks, are compared to 1e-9. - **Alice hits Bob**: the same hits, plus a raised shield, netherite, two hits a second apart, two sprinting hits, a mace smash, and a stronger hit inside the hurt cooldown. Compared: Bob's own `ClientboundSetEntityMotionPacket`, Alice's motion packets, and her sprint flag as the server sends it. - **A zombie hits Bob twice** (a real AI attack, awaited): his motion packets. ## Why A Discord report (nuuhlusinhas) says knockback is off in LAN, on servers and in single player. This harness measures it and holds the fixes in place. Since #1514 single player runs on the server thread, where the window is a guest of the same code a LAN guest or a dedicated server's player goes through. ## Result on main 7 of 21 cases match. `KNOWN` lists the other 14 and their causes. The PRs stacked on this one fix them and take them out: - **Server-side velocity** (next PR): a guest's velocity on the server never travels, so knockback adds up from hit to hit, and a mob's hit is sent before the friction of its tick. - Plain hit: 0.400 / 0.361 in vanilla; on main 0.400 / 0.400 on a fresh body, and 0.795 / 0.400 once earlier hits have added up. - Netherite: 0.240 / 0.201 in vanilla, 0.790 / 0.400 on main. - Zombie: -0.218 / 0.275 in vanilla, 0.031 / 0.400 then -0.384 / 0.400 on main. - **Sprint flag**: the server never sends a guest its own sprint flag, so a sprinting hit doesn't stop the attacker's sprint. - **Yaw**: the extra knockback's direction uses f32 sin/cos, not Mth's table, which leaves a z of -2e-8 per block. - **Mace** (not fixed here, still in `KNOWN` at the top of the stack): a smash on a player runs none of `MaceItem.hurtEnemy`. The attacker gets no motion packet and keeps falling. ## How tested ``` $ python3 tools/test_server_knockback_parity.py # on this branch (main + the harness) server knockback: 7 of 21 cases identical $ python3 tools/test_server_knockback_parity.py # top of the stack (velocity + sprint + yaw) server knockback: 20 of 21 cases identical ``` The oracle compiles with the same `javac --release 25 -proc:none` line as the other harness clients. Nothing player-facing: `skip-release`. 🤖 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:31 +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#3574
No description provided.