[PR #1412] [MERGED] Mobs: a punch shows smooth and slow, as on vanilla's client #3501

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

📋 Pull Request Information

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

Base: main ← Head: fix/mob-knockback-view


📝 Commits (10+)

  • 7acebba Server players: the HUD's bubbles and golden hearts follow the server, absorption is saved, Nether lava pushes harder
  • ed28e1d Contact damage: magma, cactus, lit campfires and sweet berry bushes hurt in both modes
  • 2898b40 Server players: an axe-disabled shield stays down 5 s, death forgets the digging
  • 5c4600e /setworldspawn moves the world spawn, not the player's respawn point
  • 65bd2d0 Items push out of blocks; a server's client digs at the server's speed
  • feeefb3 Mobs: a punch shows smooth and slow, as on vanilla's client
  • f949f08 Merge remote-tracking branch 'origin/main' into fix/server-air-absorption
  • 10f6b18 Merge branch 'fix/server-air-absorption' into fix/contact-damage
  • 48c1b04 Merge branch 'fix/contact-damage' into fix/server-player-shield-mining
  • e84f86a Merge branch 'fix/server-player-shield-mining' into fix/setworldspawn

📊 Changes

27 files changed (+1633 additions, -93 deletions)

View changed files

📝 crates/horizon-client/src/attribute_updates.rs (+5 -0)
📝 crates/horizon-client/src/entities.rs (+73 -5)
📝 crates/horizon-client/src/game.rs (+12 -3)
📝 crates/horizon-client/src/game/agent.rs (+5 -0)
📝 crates/horizon-client/src/game/commands.rs (+13 -1)
📝 crates/horizon-client/src/game/dragon.rs (+1 -0)
📝 crates/horizon-client/src/game/lan.rs (+10 -0)
📝 crates/horizon-client/src/game/lan_actions.rs (+61 -0)
📝 crates/horizon-client/src/game/lan_entities.rs (+1 -0)
📝 crates/horizon-client/src/game/remote.rs (+148 -46)
📝 crates/horizon-client/src/lan/entity.rs (+37 -2)
📝 crates/horizon-client/src/lan/guest.rs (+9 -0)
📝 crates/horizon-client/src/lan/hub.rs (+25 -1)
📝 crates/horizon-client/src/lan/playerdata.rs (+13 -1)
📝 crates/horizon-client/src/mobs.rs (+7 -0)
📝 crates/horizon-client/src/mobs/living.rs (+3 -0)
📝 crates/horizon-client/src/motion.rs (+72 -3)
📝 crates/horizon-client/src/motion/environment.rs (+1 -1)
📝 crates/horizon-client/src/save.rs (+20 -3)
📝 crates/horizon-client/tests/lan_bot.rs (+1 -0)

...and 7 more files

📄 Description

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

What

#1374 A punched mob now looks smooth and slow, as on vanilla's client, instead of the fast, old-style jump.

  • Server: a mob that was knocked back, pushed, or jumped has its move and motion sent at once (Entity.needsSync, set by LivingEntity.knockback, Entity.push and jumpFromGround; ServerEntity.sendChanges sends when it is set, due or not).
  • Client: the remote client (the window on the server thread, and LAN guests) moves every living entity along the server's positions with vanilla's SteppedInterpolationHandler, ported in horizon-world/src/stepped_interpolation.rs. Each position takes the type's update interval (3 ticks for most mobs) to reach, and the walk speeds up while steps pile up.

Fixes #1374

Why

The knockback physics already matched vanilla exactly. A frozen-tick probe gives the pig's server heights per tick as 0.361, 0.636, 0.827, 0.936, 0.965…, the same as Player.attack → causeExtraKnockback → LivingEntity.knockback (0.4).

The difference was the view:

  • Vanilla's client starts gently, about 0.12 per tick for 3 ticks, because the needsSync packet is walked over 3 interpolation ticks.
  • Horizon's server waited for the next due update, and its client then lerped there in fewer ticks, about 0.2–0.28 per tick.

How tested

  • tools/test_stepped_interpolation_parity.py (new) drives vanilla's unmodified SteppedInterpolationHandler.InterpolationData (by reflection, through VanillaSteppedInterpolationOracle) and the Rust port with the same packets and ticks. It covers about 3000 random cases (linear and stepped paths, packets with no position or no rotation, repeated packets, and packets that pile up), plus a punched pig's knockback for update intervals 1–3 and every phase. Result: 135236 positions and rotations match bit for bit.
  • A new unit test, a_knocked_back_mob_is_sent_at_once, checks that the move and motion go out on a tick that isn't due, and then every third tick again.
  • In-game probes record the pig's height, in blocks above its start, as the window or guest shows it after a punch. The fixed builds produce exactly the heights that vanilla's client model gives for that server trajectory:
View Heights after the punch
LAN guest, fixed 0.241, 0.361, 0.534, 0.701, 0.834, 0.866, 0.898, 0.816, 0.594, 0.378
Vanilla model, phase 0 0.241, 0.361, 0.534, 0.701, 0.834, 0.867, 0.898, 0.816, 0.594, 0.378
LAN guest, fixed, another run 0.241, 0.361, 0.553, 0.744, 0.936, 0.886, 0.836, 0.786, 0.524, 0.262
Vanilla model, phase 2 the same
Server-thread window, fixed 0.241, 0.381, 0.494, 0.601, 0.732, 0.862, 0.942, 0.792, 0.65, 0.476, 0.262
Vanilla model, phase 1 the same
LAN guest, before the fix 0.241, 0.436, 0.632, 0.827, … (0.195 per step)

Not fixed here: the in-frame world (HORIZON_SERVER_THREAD=0, no longer the default) still draws mobs at their simulated positions with no client interpolation. This is noted in FEATURES LATER; it goes away with the in-frame path.

Self-check

One integration commit: origin/main 357dceb9 with all six of this batch's branches merged (hud, contact, guest, spawn, items, knockback; tools/lan_e2e.py taken from the first side where they conflict). tools/pr_ready.py on the Mac mini:

pr_ready (tools/pr_ready.py on ludovics-mac-mini, against origin/main at 357dceb99, 70 min 26 s)

Check Result
Scope ⚠️ 27 files, +1327 −68; 1139 lines of code: over 500, split it if it can ship in parts
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ❌ 292 run, FAILED (errors=2) (14 s)
rustfmt ✅ (4 s)
clippy ✅ (25 s)
tests: horizon-client, horizon-world ✅ 1382 passed (3 min 25 s)
doc tests ✅ 0 passed (2 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ❌ 313 affected, 312 passed, failed: chat_screen (66 min 10 s)
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

chat_screen (1 of 3021 chat screens, the input cursor drawn on one frame) is unrelated to this batch, which touches no chat code: tools/test_chat_screen_parity.py passed twice when rerun on the same tree ("chat screen parity ok").

The Python test errors are the two that fail on main on macOS (test_parity_runner OracleReuse: java exit 127, test_rust_parity: /private/var vs /var paths).

Merging this batch

These PRs are now a chain: #1407 → #1408 → #1409 → #1410 → #1411 → #1412 → #1416 (#1308, beds). #1407 has main merged in, and each later branch merges the one before it (merge commits only), with the tools/lan_e2e.py conflicts resolved: both sides' checks kept, the shared helpers once, and every def checked with the AST against its source branch. Merge them in that order. Until the earlier ones merge, each PR also shows their commits.

On the top branch (#1416), every new check passes in both modes: absorption breath lava contacts shield deathmining worldspawn drops underwater beds minecarts levels. clippy is clean. #1408 also gained a test fix: the contacts sneaking case now sneaks before landing on the magma and reads the health before Shift is released.

What needs Ludovic

Nothing beyond review and merge.

🤖 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/1412 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/23/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/mob-knockback-view` --- ### 📝 Commits (10+) - [`7acebba`](https://github.com/horizon-rust/horizon/commit/7acebbae45fb84ec7c905e05f4ac4e4220914d0b) Server players: the HUD's bubbles and golden hearts follow the server, absorption is saved, Nether lava pushes harder - [`ed28e1d`](https://github.com/horizon-rust/horizon/commit/ed28e1dd0d6f6959179ba5f1914cfb69de14d1ae) Contact damage: magma, cactus, lit campfires and sweet berry bushes hurt in both modes - [`2898b40`](https://github.com/horizon-rust/horizon/commit/2898b40670eb253a924560d5edfe8c3a4256a725) Server players: an axe-disabled shield stays down 5 s, death forgets the digging - [`5c4600e`](https://github.com/horizon-rust/horizon/commit/5c4600e4034ed5a5a0fc50c3d498dccbc8ab04cf) /setworldspawn moves the world spawn, not the player's respawn point - [`65bd2d0`](https://github.com/horizon-rust/horizon/commit/65bd2d0d45e15710af70cad00f642ae80f48b86e) Items push out of blocks; a server's client digs at the server's speed - [`feeefb3`](https://github.com/horizon-rust/horizon/commit/feeefb3a33db6cc33c0798f535d9bdc0e7aeb306) Mobs: a punch shows smooth and slow, as on vanilla's client - [`f949f08`](https://github.com/horizon-rust/horizon/commit/f949f08488fc42b3283c20f843c45f604cf09aa0) Merge remote-tracking branch 'origin/main' into fix/server-air-absorption - [`10f6b18`](https://github.com/horizon-rust/horizon/commit/10f6b183e3dcf0fec748c90211b7871c4342e918) Merge branch 'fix/server-air-absorption' into fix/contact-damage - [`48c1b04`](https://github.com/horizon-rust/horizon/commit/48c1b04cb05dc671dbd7b6657e5cf6c6f7f94b26) Merge branch 'fix/contact-damage' into fix/server-player-shield-mining - [`e84f86a`](https://github.com/horizon-rust/horizon/commit/e84f86a813eb3c24301178f3ee4aa69dcff17384) Merge branch 'fix/server-player-shield-mining' into fix/setworldspawn ### 📊 Changes **27 files changed** (+1633 additions, -93 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/attribute_updates.rs` (+5 -0) 📝 `crates/horizon-client/src/entities.rs` (+73 -5) 📝 `crates/horizon-client/src/game.rs` (+12 -3) 📝 `crates/horizon-client/src/game/agent.rs` (+5 -0) 📝 `crates/horizon-client/src/game/commands.rs` (+13 -1) 📝 `crates/horizon-client/src/game/dragon.rs` (+1 -0) 📝 `crates/horizon-client/src/game/lan.rs` (+10 -0) 📝 `crates/horizon-client/src/game/lan_actions.rs` (+61 -0) 📝 `crates/horizon-client/src/game/lan_entities.rs` (+1 -0) 📝 `crates/horizon-client/src/game/remote.rs` (+148 -46) 📝 `crates/horizon-client/src/lan/entity.rs` (+37 -2) 📝 `crates/horizon-client/src/lan/guest.rs` (+9 -0) 📝 `crates/horizon-client/src/lan/hub.rs` (+25 -1) 📝 `crates/horizon-client/src/lan/playerdata.rs` (+13 -1) 📝 `crates/horizon-client/src/mobs.rs` (+7 -0) 📝 `crates/horizon-client/src/mobs/living.rs` (+3 -0) 📝 `crates/horizon-client/src/motion.rs` (+72 -3) 📝 `crates/horizon-client/src/motion/environment.rs` (+1 -1) 📝 `crates/horizon-client/src/save.rs` (+20 -3) 📝 `crates/horizon-client/tests/lan_bot.rs` (+1 -0) _...and 7 more files_ </details> ### 📄 Description > 🤖 Opened by Ludovic's AI agent (Claude), not by Ludovic himself. ## What **#1374** A punched mob now looks smooth and slow, as on vanilla's client, instead of the fast, old-style jump. - **Server:** a mob that was knocked back, pushed, or jumped has its move and motion sent at once (`Entity.needsSync`, set by `LivingEntity.knockback`, `Entity.push` and `jumpFromGround`; `ServerEntity.sendChanges` sends when it is set, due or not). - **Client:** the remote client (the window on the server thread, and LAN guests) moves every living entity along the server's positions with vanilla's `SteppedInterpolationHandler`, ported in `horizon-world/src/stepped_interpolation.rs`. Each position takes the type's update interval (3 ticks for most mobs) to reach, and the walk speeds up while steps pile up. Fixes #1374 ## Why The knockback physics already matched vanilla exactly. A frozen-tick probe gives the pig's server heights per tick as 0.361, 0.636, 0.827, 0.936, 0.965…, the same as `Player.attack` → `causeExtraKnockback` → `LivingEntity.knockback` (0.4). The difference was the view: - Vanilla's client starts gently, about 0.12 per tick for 3 ticks, because the `needsSync` packet is walked over 3 interpolation ticks. - Horizon's server waited for the next due update, and its client then lerped there in fewer ticks, about 0.2–0.28 per tick. ## How tested - `tools/test_stepped_interpolation_parity.py` (new) drives vanilla's unmodified `SteppedInterpolationHandler.InterpolationData` (by reflection, through `VanillaSteppedInterpolationOracle`) and the Rust port with the same packets and ticks. It covers about 3000 random cases (linear and stepped paths, packets with no position or no rotation, repeated packets, and packets that pile up), plus a punched pig's knockback for update intervals 1–3 and every phase. Result: **135236 positions and rotations match bit for bit.** - A new unit test, `a_knocked_back_mob_is_sent_at_once`, checks that the move and motion go out on a tick that isn't due, and then every third tick again. - In-game probes record the pig's height, in blocks above its start, as the window or guest shows it after a punch. The fixed builds produce exactly the heights that vanilla's client model gives for that server trajectory: | View | Heights after the punch | | --- | --- | | LAN guest, fixed | 0.241, 0.361, 0.534, 0.701, 0.834, 0.866, 0.898, 0.816, 0.594, 0.378 | | Vanilla model, phase 0 | 0.241, 0.361, 0.534, 0.701, 0.834, 0.867, 0.898, 0.816, 0.594, 0.378 | | LAN guest, fixed, another run | 0.241, 0.361, 0.553, 0.744, 0.936, 0.886, 0.836, 0.786, 0.524, 0.262 | | Vanilla model, phase 2 | the same | | Server-thread window, fixed | 0.241, 0.381, 0.494, 0.601, 0.732, 0.862, 0.942, 0.792, 0.65, 0.476, 0.262 | | Vanilla model, phase 1 | the same | | LAN guest, before the fix | 0.241, 0.436, 0.632, 0.827, … (0.195 per step) | Not fixed here: the in-frame world (`HORIZON_SERVER_THREAD=0`, no longer the default) still draws mobs at their simulated positions with no client interpolation. This is noted in FEATURES LATER; it goes away with the in-frame path. ### Self-check One integration commit: origin/main 357dceb9 with all six of this batch's branches merged (hud, contact, guest, spawn, items, knockback; `tools/lan_e2e.py` taken from the first side where they conflict). `tools/pr_ready.py` on the Mac mini: **pr_ready** (`tools/pr_ready.py` on ludovics-mac-mini, against origin/main at 357dceb99, 70 min 26 s) | Check | Result | | --- | --- | | Scope | ⚠️ 27 files, +1327 −68; 1139 lines of code: over 500, split it if it can ship in parts | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ❌ 292 run, FAILED (errors=2) (14 s) | | rustfmt | ✅ (4 s) | | clippy | ✅ (25 s) | | tests: horizon-client, horizon-world | ✅ 1382 passed (3 min 25 s) | | doc tests | ✅ 0 passed (2 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ❌ 313 affected, 312 passed, failed: chat_screen (66 min 10 s) | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | `chat_screen` (1 of 3021 chat screens, the input cursor drawn on one frame) is unrelated to this batch, which touches no chat code: `tools/test_chat_screen_parity.py` passed twice when rerun on the same tree ("chat screen parity ok"). The Python test errors are the two that fail on main on macOS (`test_parity_runner` OracleReuse: java exit 127, `test_rust_parity`: /private/var vs /var paths). ### Merging this batch These PRs are now a chain: #1407 → #1408 → #1409 → #1410 → #1411 → #1412 → #1416 (#1308, beds). #1407 has main merged in, and each later branch merges the one before it (merge commits only), with the `tools/lan_e2e.py` conflicts resolved: both sides' checks kept, the shared helpers once, and every def checked with the AST against its source branch. Merge them in that order. Until the earlier ones merge, each PR also shows their commits. On the top branch (#1416), every new check passes in both modes: `absorption breath lava contacts shield deathmining worldspawn drops underwater beds minecarts levels`. clippy is clean. #1408 also gained a test fix: the `contacts` sneaking case now sneaks before landing on the magma and reads the health before Shift is released. ### What needs Ludovic Nothing beyond review and merge. 🤖 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:09:59 +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#3501
No description provided.