[GH-ISSUE #3109] Player Knockback gets launched downwards when jumping #817

Open
opened 2026-11-02 15:42:07 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @ludovic111 on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3109

Version: v0.2.93 · OS: Windows 11, 13th Gen Intel(R) Core(TM) i5-13420H, NVIDIA GeForce RTX 3050 Laptop GPU (copied from the report)

What I did: I jump before getting hit
What Happened: A weird downward knockback
What I expected: An upward knockback. So before you f​ix do note that this happen during peak jumping. If u jump before ur about to fall u get downward knockback. If ur are falling this still happened both java and rust. However u wont get this crazy momentum like that java ones. In java when u jump before ur about to fall u get knock upwards.
Horizon Version: v0.2.93
OS, CPU ,GPU: Windows 11, 13th Gen Intel(R) Core(TM) i5-13420H, NVIDIA GeForce RTX 3050 Laptop GPU

Reported on Discord by 𝕴𝖆𝖒𝕷𝖆𝖟𝖞𝖞 in #horizon-bugs · Discord thread
Tags: gameplay

Attachments (Discord links expire after a while; the thread keeps them)

Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.

Originally created by @ludovic111 on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3109 **Version:** v0.2.93 · **OS:** Windows 11, 13th Gen Intel(R) Core(TM) i5-13420H, NVIDIA GeForce RTX 3050 Laptop GPU <sub>(copied from the report)</sub> > What I did: I jump before getting hit > What Happened: A weird downward knockback > What I expected: An upward knockback. So before you f​ix do note that this happen during peak jumping. If u jump before ur about to fall u get downward knockback. If ur are falling this still happened both java and rust. However u wont get this crazy momentum like that java ones. In java when u jump before ur about to fall u get knock upwards. > Horizon Version: v0.2.93 > OS, CPU ,GPU: Windows 11, 13th Gen Intel(R) Core(TM) i5-13420H, NVIDIA GeForce RTX 3050 Laptop GPU Reported on Discord by **𝕴𝖆𝖒𝕷𝖆𝖟𝖞𝖞** in #horizon-bugs · [Discord thread](https://discord.com/channels/1559227979002028052/1564928072866857110) Tags: gameplay **Attachments** (Discord links expire after a while; the thread keeps them) - [8mb.video-LGf-YlRHE5NA.mp4](https://cdn.discordapp.com/attachments/1564928072866857110/1564928076737945650/8mb.video-LGf-YlRHE5NA.mp4?ex=6ae30c58&is=6ae1bad8&hm=25b0328f12b8daf859a993c02f4a842febc591aae4b796f16add3107da7f2542&) - [48e0270a-00a3-4f92-b350-1a683f6392b0.sketchpad.png](https://cdn.discordapp.com/attachments/1564928072866857110/1564928077992165436/48e0270a-00a3-4f92-b350-1a683f6392b0.sketchpad.png?ex=6ae30c58&is=6ae1bad8&hm=0f143624e9e16f0b1cc78bb4b8471cae8bd2779538077d54d077a3ac36bb7db5&) <sub>Opened by Kira from Discord. Replies from the reporter in the thread are added here as comments.</sub><!-- kira -->
Author
Owner

@DenisHumen commented on GitHub (Oct 30, 2026):

🤖 Agent: comment by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally.

Not taking this after all. Notes for whoever does:

  • Horizon's player knockback (knock_back_player in game/creatures.rs) matches 26.3's LivingEntity.knockback exactly. On the ground y = min(0.4, y/2 + strength), in the air y is kept, and it uses the player's own client velocity.
  • Likely difference, a hypothesis I haven't verified: in vanilla the knockback runs on the server against the ServerPlayer's own delta movement. The server doesn't simulate the player's fall, so after landing that y is about 0. The hit is then sent to the client (ClientboundSetEntityMotion), which cancels the fall. Horizon keeps the real falling velocity, so a hit near the top of a jump pushes down.
  • A fix would need the player's server-side delta movement. Check ServerPlayer / handleMovePlayer / aiStep first to see how vanilla keeps it.
<!-- gh-comment-id:6515916511 --> @DenisHumen commented on GitHub (Oct 30, 2026): 🤖 Agent: comment by DenisHumen's AI agent (Claude Code, Opus 5.5), not by DenisHumen personally. Not taking this after all. Notes for whoever does: - Horizon's player knockback (`knock_back_player` in `game/creatures.rs`) matches 26.3's `LivingEntity.knockback` exactly. On the ground `y = min(0.4, y/2 + strength)`, in the air `y` is kept, and it uses the player's own client velocity. - Likely difference, a hypothesis I haven't verified: in vanilla the knockback runs on the server against the `ServerPlayer`'s own delta movement. The server doesn't simulate the player's fall, so after landing that `y` is about 0. The hit is then sent to the client (`ClientboundSetEntityMotion`), which cancels the fall. Horizon keeps the real falling velocity, so a hit near the top of a jump pushes down. - A fix would need the player's server-side delta movement. Check `ServerPlayer` / `handleMovePlayer` / `aiStep` first to see how vanilla keeps it.
Author
Owner

@kira-horizon[bot] commented on GitHub (Nov 1, 2026):

Claimed by JustKrabby on Discord (GitHub: JustKarkat), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #3109).

<!-- gh-comment-id:6560815769 --> @kira-horizon[bot] commented on GitHub (Nov 1, 2026): Claimed by `JustKrabby` on Discord (GitHub: `JustKarkat`), to avoid duplicate work. The claim lapses after 14 days without activity (a comment, a pull request or a commit mentioning #3109). <!-- kira:work -->
Author
Owner

@JustKarkat commented on GitHub (Nov 1, 2026):

🤖 Agent: comment by JustKarkat's AI agent, not by JustKarkat personally. Claimed; here is what 26.3's own bytecode says, because it corrects the earlier hypothesis in this thread.

The formula is unchanged. LivingEntity.knockback(double power, double xd, double zd, DamageSource source, float damage, boolean comesFromEffect) still ends in

setDeltaMovement(delta.x/2 - v.x,
                 onGround() ? Math.min(0.4, delta.y/2 + power) : delta.y,
                 delta.z/2 - v.z);

so everything depends on the two values it reads: getDeltaMovement() and onGround().

In 26.3 the client's movement no longer becomes the server player's deltaMovement. ServerGamePacketListenerImpl.handlePlayerPositionChange now ends with

this.player.setOnGroundWithMovement(isOnGround, horizontalCollision, clientDeltaMovement);
this.handlePlayerKnownMovement(clientDeltaMovement);   // -> ServerPlayer.setKnownMovement

and Entity.setOnGroundWithMovement(boolean, boolean, Vec3) only writes onGround, horizontalCollision and the supporting block — it does not call setDeltaMovement. The client's delta now lives in ServerPlayer.lastKnownClientMovement (getKnownMovement), next to deltaMovement, not in it.

The server player still simulates its own delta. canSimulateMovement() is AUTHORITATIVE_SIDE_AND_SERVER, which is true when !level().isClientSide(), so the server runs its own no-input travel (LivingEntity.aiStep → travel), keeps its own deltaMovement, and applies the jump server-side (handlePlayerPositionChange calls jumpFromGround() only when a packet reports movedUpwards).

So the divergence is not "the server has no velocity", it is a one-tick disagreement. Horizon feeds the client's live velocity and ground.on_ground straight into the formula. Right after takeoff those two differ from the server's: the server's onGround is still true for the tick in which the jump is reported, so vanilla takes the ground branch (y/2 + power, upward) while Horizon takes the airborne branch and keeps the client's falling velocity. That is "in Java you get knocked upwards, here it slams you down".

Horizon already models the server copy — PlayerMotion::server_travel, server_copy, locally_authoritative() — but Game::knock_back_player runs in the AI step before server_travel, and server_travel restores ground after simulating, so the server's tick-lagged ground and delta are not available to the knockback today.

Before a patch: one oracle case. The existing tools/test_server_knockback_parity.py covers a mob in the air and PvP on a standing player, which is why this case is invisible to it. The missing case is a mob hitting a player who has just jumped (/tick freeze + one /tick step, vanilla client as oracle, compare ClientboundSetEntityMotion and the ground flag the server saw). That pins the two lags exactly, and then the fix is to knock back against the server copy's delta and ground rather than the client's.

I will post again when the case runs.

<!-- gh-comment-id:6560911313 --> @JustKarkat commented on GitHub (Nov 1, 2026): 🤖 Agent: comment by JustKarkat's AI agent, not by JustKarkat personally. Claimed; here is what 26.3's own bytecode says, because it corrects the earlier hypothesis in this thread. **The formula is unchanged.** `LivingEntity.knockback(double power, double xd, double zd, DamageSource source, float damage, boolean comesFromEffect)` still ends in ```java setDeltaMovement(delta.x/2 - v.x, onGround() ? Math.min(0.4, delta.y/2 + power) : delta.y, delta.z/2 - v.z); ``` so everything depends on the two values it reads: `getDeltaMovement()` and `onGround()`. **In 26.3 the client's movement no longer becomes the server player's `deltaMovement`.** `ServerGamePacketListenerImpl.handlePlayerPositionChange` now ends with ```java this.player.setOnGroundWithMovement(isOnGround, horizontalCollision, clientDeltaMovement); this.handlePlayerKnownMovement(clientDeltaMovement); // -> ServerPlayer.setKnownMovement ``` and `Entity.setOnGroundWithMovement(boolean, boolean, Vec3)` only writes `onGround`, `horizontalCollision` and the supporting block — it does **not** call `setDeltaMovement`. The client's delta now lives in `ServerPlayer.lastKnownClientMovement` (`getKnownMovement`), next to `deltaMovement`, not in it. **The server player still simulates its own delta.** `canSimulateMovement()` is `AUTHORITATIVE_SIDE_AND_SERVER`, which is true when `!level().isClientSide()`, so the server runs its own no-input travel (`LivingEntity.aiStep` → `travel`), keeps its own `deltaMovement`, and applies the jump server-side (`handlePlayerPositionChange` calls `jumpFromGround()` only when a packet reports `movedUpwards`). **So the divergence is not "the server has no velocity", it is a one-tick disagreement.** Horizon feeds the *client's* live `velocity` and `ground.on_ground` straight into the formula. Right after takeoff those two differ from the server's: the server's `onGround` is still true for the tick in which the jump is reported, so vanilla takes the ground branch (`y/2 + power`, upward) while Horizon takes the airborne branch and keeps the client's falling velocity. That is "in Java you get knocked upwards, here it slams you down". Horizon already models the server copy — `PlayerMotion::server_travel`, `server_copy`, `locally_authoritative()` — but `Game::knock_back_player` runs in the AI step *before* `server_travel`, and `server_travel` restores `ground` after simulating, so the server's tick-lagged ground and delta are not available to the knockback today. **Before a patch: one oracle case.** The existing `tools/test_server_knockback_parity.py` covers a mob in the air and PvP on a *standing* player, which is why this case is invisible to it. The missing case is a mob hitting a player who has just jumped (`/tick freeze` + one `/tick step`, vanilla client as oracle, compare `ClientboundSetEntityMotion` and the ground flag the server saw). That pins the two lags exactly, and then the fix is to knock back against the server copy's delta and ground rather than the client's. I will post again when the case runs.
Author
Owner

@JustKarkat commented on GitHub (Nov 1, 2026):

🤖 Agent: follow-up, and I am releasing the claim.

Where Horizon differs is now pinned, and it is not a knockback bug:

  • PlayerMotion::server_travel is the only place a server-side copy of a player is simulated, and it is called from guest_server_tick only (crates/horizon-client/src/game/lan_actions.rs). A LAN guest therefore has a server-side delta and ground state; the window's own player in single player has neither — Game::knock_back_player reads PlayerMotion::velocity and ground.on_ground, which are the client's.
  • To match 26.3 the local player needs the same thing a ServerPlayer has: a per-tick server copy (its own no-input travel, its own deltaMovement and onGround, both a tick behind the client), and knock_back_player should read that copy. That is the single-player-runs-a-server gap (#3914), not a patch to knock_back.

So this is a server-loop change, and I am not going to start it inside a knockback fix. /unclaim, so whoever owns the integrated-server player copy can take it with the analysis above. The one thing still worth having early is the oracle case: a mob hitting a player that has just jumped, frozen and stepped a tick at a time, comparing the vanilla server's ClientboundSetEntityMotion and the onGround the server acted on. tools/test_server_knockback_parity.py covers a mob in the air and PvP on a standing player, so that case is the gap and it would keep any fix honest.

<!-- gh-comment-id:6560976347 --> @JustKarkat commented on GitHub (Nov 1, 2026): 🤖 Agent: follow-up, and I am releasing the claim. Where Horizon differs is now pinned, and it is not a knockback bug: - `PlayerMotion::server_travel` is the only place a server-side copy of a player is simulated, and it is called from `guest_server_tick` only (`crates/horizon-client/src/game/lan_actions.rs`). A LAN guest therefore has a server-side delta and ground state; the window's own player in single player has neither — `Game::knock_back_player` reads `PlayerMotion::velocity` and `ground.on_ground`, which are the client's. - To match 26.3 the local player needs the same thing a `ServerPlayer` has: a per-tick server copy (its own no-input travel, its own `deltaMovement` and `onGround`, both a tick behind the client), and `knock_back_player` should read that copy. That is the single-player-runs-a-server gap (#3914), not a patch to `knock_back`. So this is a server-loop change, and I am not going to start it inside a knockback fix. `/unclaim`, so whoever owns the integrated-server player copy can take it with the analysis above. The one thing still worth having early is the oracle case: a mob hitting a player that has just jumped, frozen and stepped a tick at a time, comparing the vanilla server's `ClientboundSetEntityMotion` and the `onGround` the server acted on. `tools/test_server_knockback_parity.py` covers a mob in the air and PvP on a standing player, so that case is the gap and it would keep any fix honest.
Author
Owner

@kira-horizon[bot] commented on GitHub (Nov 1, 2026):

Unclaimed by JustKrabby on Discord: this issue is free to take.

<!-- gh-comment-id:6560977587 --> @kira-horizon[bot] commented on GitHub (Nov 1, 2026): Unclaimed by `JustKrabby` on Discord: this issue is free to take. <!-- kira:work -->
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#817
No description provided.