[PR #4035] [MERGED] Ender Dragon wings push the player only when their hit lands #5371

Closed
opened 2026-11-03 05:12:07 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/4035
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-2893


📝 Commits (1)

  • b3fdebc Ender Dragon wings push the player only when their hit lands

📊 Changes

1 file changed (+100 additions, -11 deletions)

View changed files

📝 crates/horizon-client/src/game/dragon.rs (+100 -11)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

What and why

Under the Ender Dragon's wings the player got flung by several blocks per tick, perched dragon or not, which made reaching the exit portal very hard.

Cause: dragon_contacts (game/dragon.rs) added the wing push (xd / dd * 4, 0.2, zd / dd * 4) straight to the player's velocity on every tick they stayed in a wing's zone. In vanilla, EnderDragon.knockBack calls Entity.push on the server's copy of the player. That only sets needsSync, which sends the motion to the players tracking them, not to the player. A player's own client gets its velocity only when a hurt marks it (LivingEntity.hurtServer → markHurt → ServerEntity.sendChanges sends ClientboundSetEntityMotionPacket to the player too). The hurt (5, mobAttack) happens only when the dragon is not isSitting() and the player's getLastHurtByMobTimestamp() < tickCount - 2, and it lands only outside the hurt cooldown. So in vanilla the push reaches the player's client at most once per 10 ticks while the dragon flies through, and never while it is perched.

Fix: a new dragon_wing_knock_back runs per player per wing (host or server/LAN guest, through as_fight_player):

  • it applies the 5-damage hurt only when the dragon is not sitting and no mob hurt the player in the last 2 ticks (that gate was missing).
  • push_seen_with_hurt keeps the push only when this hurt marked the velocity (health.sync_velocity), and drops it otherwise. An earlier mark is kept, so a guest's velocity still goes out after its server tick, as before.
  • the vertical push is 0.2f widened (0.20000000298023224), as in the bytecode.

The head and neck hits (hurt, 10 damage) are unchanged.

Not modelled: vanilla's server copy of the player keeps the pushes that came with no landed hurt in its deltaMovement (the client's move packets don't reset it), so the next hurt that does land sends them along. Horizon drops them instead.

Fixes #2893

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

Read with javap from the 26.3 jars:

  • EnderDragon.aiStep: knockBack on each wing's box inflate(4, 2, 4).move(0, -2, 0) with EntitySelector.NO_CREATIVE_OR_SPECTATOR, unless wasHurtRecently().
  • EnderDragon.knockBack(ServerLevel, List): Entity.push(xd / d * 4, 0.2f, zd / d * 4), then hurtServer(mobAttack, 5) only if !phaseManager.getCurrentPhase().isSitting(), getLastHurtByMobTimestamp() < tickCount - 2 and doTeamsAllowDamage.
  • Entity.push(double, double, double): sets needsSync. Entity.markHurt sets syncVelocity.
  • ServerEntity.sendChanges: needsSync motion goes to sendToTrackingPlayers. syncVelocity goes to sendToTrackingPlayersAndSelf.
  • LivingEntity.hurtServer: markHurt only for a hit that is not in the hurt cooldown.

Test: game::dragon::tests::a_wing_pushes_the_player_only_with_a_landed_hurt (the player's real PlayerMotion and damage rules). It checks that:

  • the first hit pushes the player.
  • the next 9 ticks inside the cooldown neither hurt nor push.
  • the 10th tick pushes again.
  • 20 ticks under a perched dragon's wing leave the velocity at zero.

No parity harness covers the dragon fight.

Self-check

Run on Windows. tools/pr_ready.py does not run there, so I ran its steps by hand:

  • cargo fmt --all -- --check: clean
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean
  • cargo test --profile fast -p horizon-client --bin horizon-client game::dragon::: 8 passed
  • The new test with the old push logic (push added on every call) put back in push_seen_with_hurt: fails, pushed again with no hurt, left (5.0, 2.0000000298023224, -2.5) vs right (0.5, 0.20000000298023224, -0.25). With the fix: passes.
  • In game, single player on the server thread (the window player is a client of the integrated server, the same path as a LAN or server guest). The setup was a survival player in the End with Resistance and Regeneration and the crystals removed, kept beside the exit portal at (3.5, 0.5). I sampled horizon-ctl status about every 50 ms, and put the player back whenever they were pushed more than 2 blocks off the spot:
    • before (main): 1277 samples with the dragon perched. In 1271 of them the player moved at more than 0.3 blocks/tick horizontally (2.5 to 7 blocks/tick), and they had to be put back 780 times. Health stayed at 20: the push came with no hurt at all.
    • after: 2727 samples with the dragon perched. The player stood still under it. 4 samples were just over 0.3 blocks/tick and the player was put back 5 times, all slow drift, none of it from the wings. While the dragon flew through (landing and takeoff), wing hits still landed (health 20 → 19) and still pushed, now once per hit.

Screenshots

Players see this as movement, which still screenshots don't capture well. Before: standing next to the perched dragon at the exit portal flings the player away from it on every tick. After: the player can stand under a perched dragon's wings. A wing still knocks them back, once per hit, when it hits them as the dragon flies through.

🤖 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/4035 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-2893` --- ### 📝 Commits (1) - [`b3fdebc`](https://github.com/horizon-rust/horizon/commit/b3fdebcb92dacfe9cfd0c5821aaaa5c433611d2b) Ender Dragon wings push the player only when their hit lands ### 📊 Changes **1 file changed** (+100 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dragon.rs` (+100 -11) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Under the Ender Dragon's wings the player got flung by several blocks per tick, perched dragon or not, which made reaching the exit portal very hard. Cause: `dragon_contacts` (`game/dragon.rs`) added the wing push (`xd / dd * 4`, `0.2`, `zd / dd * 4`) straight to the player's velocity on **every tick** they stayed in a wing's zone. In vanilla, `EnderDragon.knockBack` calls `Entity.push` on the server's copy of the player. That only sets `needsSync`, which sends the motion to the players *tracking* them, not to the player. A player's own client gets its velocity only when a hurt marks it (`LivingEntity.hurtServer` → `markHurt` → `ServerEntity.sendChanges` sends `ClientboundSetEntityMotionPacket` to the player too). The hurt (5, `mobAttack`) happens only when the dragon is not `isSitting()` and the player's `getLastHurtByMobTimestamp() < tickCount - 2`, and it lands only outside the hurt cooldown. So in vanilla the push reaches the player's client at most once per 10 ticks while the dragon flies through, and never while it is perched. Fix: a new `dragon_wing_knock_back` runs per player per wing (host or server/LAN guest, through `as_fight_player`): - it applies the 5-damage hurt only when the dragon is not sitting and no mob hurt the player in the last 2 ticks (that gate was missing). - `push_seen_with_hurt` keeps the push only when this hurt marked the velocity (`health.sync_velocity`), and drops it otherwise. An earlier mark is kept, so a guest's velocity still goes out after its server tick, as before. - the vertical push is `0.2f` widened (`0.20000000298023224`), as in the bytecode. The head and neck hits (`hurt`, 10 damage) are unchanged. Not modelled: vanilla's server copy of the player keeps the pushes that came with no landed hurt in its `deltaMovement` (the client's move packets don't reset it), so the next hurt that does land sends them along. Horizon drops them instead. Fixes #2893 ## Kind - [x] parity: Horizon now does what vanilla 26.3 does - [ ] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference Read with javap from the 26.3 jars: - `EnderDragon.aiStep`: `knockBack` on each wing's box `inflate(4, 2, 4).move(0, -2, 0)` with `EntitySelector.NO_CREATIVE_OR_SPECTATOR`, unless `wasHurtRecently()`. - `EnderDragon.knockBack(ServerLevel, List)`: `Entity.push(xd / d * 4, 0.2f, zd / d * 4)`, then `hurtServer(mobAttack, 5)` only if `!phaseManager.getCurrentPhase().isSitting()`, `getLastHurtByMobTimestamp() < tickCount - 2` and `doTeamsAllowDamage`. - `Entity.push(double, double, double)`: sets `needsSync`. `Entity.markHurt` sets `syncVelocity`. - `ServerEntity.sendChanges`: `needsSync` motion goes to `sendToTrackingPlayers`. `syncVelocity` goes to `sendToTrackingPlayersAndSelf`. - `LivingEntity.hurtServer`: `markHurt` only for a hit that is not in the hurt cooldown. Test: `game::dragon::tests::a_wing_pushes_the_player_only_with_a_landed_hurt` (the player's real `PlayerMotion` and damage rules). It checks that: - the first hit pushes the player. - the next 9 ticks inside the cooldown neither hurt nor push. - the 10th tick pushes again. - 20 ticks under a perched dragon's wing leave the velocity at zero. No parity harness covers the dragon fight. ## Self-check Run on Windows. `tools/pr_ready.py` does not run there, so I ran its steps by hand: - `cargo fmt --all -- --check`: clean - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean - `cargo test --profile fast -p horizon-client --bin horizon-client game::dragon::`: 8 passed - The new test with the old push logic (push added on every call) put back in `push_seen_with_hurt`: **fails**, `pushed again with no hurt`, left `(5.0, 2.0000000298023224, -2.5)` vs right `(0.5, 0.20000000298023224, -0.25)`. With the fix: **passes**. - In game, single player on the server thread (the window player is a client of the integrated server, the same path as a LAN or server guest). The setup was a survival player in the End with Resistance and Regeneration and the crystals removed, kept beside the exit portal at (3.5, 0.5). I sampled `horizon-ctl status` about every 50 ms, and put the player back whenever they were pushed more than 2 blocks off the spot: - before (main): 1277 samples with the dragon perched. In 1271 of them the player moved at more than 0.3 blocks/tick horizontally (2.5 to 7 blocks/tick), and they had to be put back 780 times. Health stayed at 20: the push came with no hurt at all. - after: 2727 samples with the dragon perched. The player stood still under it. 4 samples were just over 0.3 blocks/tick and the player was put back 5 times, all slow drift, none of it from the wings. While the dragon flew through (landing and takeoff), wing hits still landed (health 20 → 19) and still pushed, now once per hit. ## Screenshots Players see this as movement, which still screenshots don't capture well. Before: standing next to the perched dragon at the exit portal flings the player away from it on every tick. After: the player can stand under a perched dragon's wings. A wing still knocks them back, once per hit, when it hits them as the dragon flies through. 🤖 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 05:12: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#5371
No description provided.