[PR #4069] [MERGED] Creative players are pushed by explosions and crystals #5397

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

📋 Pull Request Information

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

Base: main ← Head: fix-2755


📝 Commits (5)

  • 51cd540 Creative players are pushed by explosions and crystals
  • 152258b server_knockback harness: creative players near a crystal and TNT
  • d5fd62c Merge origin/main into fix-2755
  • 41d70dc Merge hr/main into fix-2755
  • a712692 Merge hr/main into fix-2755

📊 Changes

5 files changed (+72 additions, -33 deletions)

View changed files

📝 crates/horizon-client/src/game/creatures.rs (+3 -2)
📝 crates/horizon-client/src/game/explosion.rs (+33 -18)
📝 crates/horizon-client/src/game/lan_particles.rs (+10 -7)
📝 mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java (+7 -3)
📝 tools/test_server_knockback_parity.py (+19 -3)

📄 Description

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

What and why

Fixes #2755. The survival part of that report (too little knockback from a crystal) was already fixed by #2730, as the issue's comments measured; this fixes the rest, the creative part. In creative, an explosion doesn't move you. An end crystal you hit leaves you standing still on the default server-thread path, on a LAN guest and on a dedicated server.

Root cause. The server pushes its own copy of the player (explosion_hurt_player). The client only learns about the push from a motion packet, and that packet is sent only when a hurt marks the velocity (health.sync_velocity, set by mark_hurt). A creative player takes no damage, so nothing is marked:

  • A crystal you hit yourself: the blast runs in your own turn (guest_attack). That path sends your velocity only when sync_velocity is set, so you get nothing.
  • TNT, or a crystal someone else hits on a server tick: guest_hit_by sees a push with no hurt and sends the server copy's whole velocity as a motion packet. That replaces the client's own motion instead of adding to it.
  • The explosion packet: it always went out with no push (send_explosion(packet, &[])).

Vanilla. ServerExplosion.hurtEntities puts every pushed player into hitPlayers, unless they are a spectator or a creative player who is flying. ServerLevel.explode then sends each player ClientboundExplodePacket with playerKnockback = hitPlayers.get(player), and ClientPacketListener.handleExplosion adds it to the player's motion. A creative player isn't hurt (Player.isInvulnerableTo), so this push is the only one their client gets.

Fix.

  • explosion_hurt_player now returns the push it gave.
  • explosion_hurt_entities collects one push per guest, including the acting guest in their own turn, the way wind_knockback already does for wind bursts.
  • server_explode_as passes those pushes to lan_explode, and through its guest-turn deferral (creatures.lan_explosions). send_explosion puts each player's push into their packet.

Hurt players are left out of the packet. A player whose velocity a hurt marked still gets the whole velocity, push included, from the motion packet once their server copy has travelled (Entity.markHurt, then ServerEntity.sendChanges). In vanilla that later motion packet replaces whatever the explosion packet added, so the end result is the same. Adding the push to their packet as well would push them twice in a guest's own turn, because that motion packet goes out before the deferred explosion packet. (On the vanilla server, a survival player at the harness's crystal spot gets explode push -0.64755 0.52452 0.00000 and then motion self -0.64756 0.44613 0.00000, and the motion packet sets their velocity.)

Found while testing, not fixed here: someone else's crystal still doesn't push or hurt the players around it. While a player's turn runs, the host is taken out of Game, so explosion_hurt_entities reaches only that player. In game, a survival host standing 3 blocks from a crystal a LAN guest hit took no damage and didn't move. That needs a separate change to how a turn reaches the other players.

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

  • ServerExplosion.hurtEntities: pushFromExplosion, then hitPlayers.put(player, knockback) unless isSpectator(), or isCreative() && getAbilities().flying.
  • ServerLevel.explode: ClientboundExplodePacket(..., Optional.ofNullable(hitPlayers.get(player)), ...) to each player within 64 blocks.
  • ClientPacketListener.handleExplosion: playerKnockback is added to the player's motion.
  • Player.isInvulnerableTo: a creative player takes no explosion damage, so there is no markHurt and no motion packet.

Harness: tools/test_server_knockback_parity.py has two new cases, crystal-creative (Bob in creative hits an end crystal 2 blocks away) and tnt-creative (primed TNT goes off 2 blocks from Bob in creative). KnockbackClient now records the push each ClientboundExplodePacket carries. Both cases match vanilla exactly: Bob gets explode push -0.64755 0.52452 0.00000 and -0.59146 0.46097 0.00000, with no motion packet, and Alice's packet carries no push.

Self-check

tools/pr_ready.py doesn't run on Windows, so I ran these by hand:

  • cargo fmt --all -- --check: clean.
  • cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • cargo build --profile fast -p horizon-client --bins: ok.
  • python tools/test_server_knockback_parity.py:
    • Code reverted, harness kept: fails with "2 cases differ".
      crystal-creative:
      -Bob explode push -0.64755 0.52452 0.00000
      +Bob explode push none
      tnt-creative:
      -Bob explode push -0.59146 0.46097 0.00000
      +Bob motion self -0.59147 0.38259 0.00000
      +Bob explode push none
      
    • With the fix: server knockback: 22 of 23 cases identical. The one left is pvp-mace, which is already in KNOWN.
  • In game, server thread, creative. I hit an end crystal 3 blocks away:
    • Before: position 531.5 -> 531.5, velocity unchanged.
    • After: pushed to 528.50, with a first-tick velocity of (0, -0.048, -0.27).
    • TNT 2 blocks away pushed the player before the fix too, but through the motion packet that replaces the client's velocity. It now pushes through the explosion packet (531.5 -> 528.59).
  • LAN guest, creative, with the fix. A second game joined over LAN and hit a crystal, and was pushed 555.5 -> 552.50. The before case for a guest is the harness's crystal-creative above: its players are guests on the same server code.

Screenshots

Before: after hitting the crystal, the creative player is still standing at the edge of the crater. After: the blast throws the player about 3 blocks back, and the crater is in the distance.

🤖 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/4069 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/30/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-2755` --- ### 📝 Commits (5) - [`51cd540`](https://github.com/horizon-rust/horizon/commit/51cd5409da224784059f82b21281c0eb33cf9533) Creative players are pushed by explosions and crystals - [`152258b`](https://github.com/horizon-rust/horizon/commit/152258bb839995d080a7628d37ac74c3fa402a47) server_knockback harness: creative players near a crystal and TNT - [`d5fd62c`](https://github.com/horizon-rust/horizon/commit/d5fd62c2985676ff5458bd7308269c0666318ed6) Merge origin/main into fix-2755 - [`41d70dc`](https://github.com/horizon-rust/horizon/commit/41d70dc6c5d3db6f49fd42df5ace1523c15b35b5) Merge hr/main into fix-2755 - [`a712692`](https://github.com/horizon-rust/horizon/commit/a7126925276ff44f78ec76bd0c99748f22d514be) Merge hr/main into fix-2755 ### 📊 Changes **5 files changed** (+72 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/creatures.rs` (+3 -2) 📝 `crates/horizon-client/src/game/explosion.rs` (+33 -18) 📝 `crates/horizon-client/src/game/lan_particles.rs` (+10 -7) 📝 `mods/horizon/src/test/java/dev/horizonlab/parity/KnockbackClient.java` (+7 -3) 📝 `tools/test_server_knockback_parity.py` (+19 -3) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. ## What and why Fixes #2755. The survival part of that report (too little knockback from a crystal) was already fixed by #2730, as the issue's comments measured; this fixes the rest, the creative part. In creative, an explosion doesn't move you. An end crystal you hit leaves you standing still on the default server-thread path, on a LAN guest and on a dedicated server. **Root cause.** The server pushes its own copy of the player (`explosion_hurt_player`). The client only learns about the push from a motion packet, and that packet is sent only when a hurt marks the velocity (`health.sync_velocity`, set by `mark_hurt`). A creative player takes no damage, so nothing is marked: - **A crystal you hit yourself:** the blast runs in your own turn (`guest_attack`). That path sends your velocity only when `sync_velocity` is set, so you get nothing. - **TNT, or a crystal someone else hits on a server tick:** `guest_hit_by` sees a push with no hurt and sends the server copy's whole velocity as a motion packet. That replaces the client's own motion instead of adding to it. - **The explosion packet:** it always went out with no push (`send_explosion(packet, &[])`). **Vanilla.** `ServerExplosion.hurtEntities` puts every pushed player into `hitPlayers`, unless they are a spectator or a creative player who is flying. `ServerLevel.explode` then sends each player `ClientboundExplodePacket` with `playerKnockback = hitPlayers.get(player)`, and `ClientPacketListener.handleExplosion` adds it to the player's motion. A creative player isn't hurt (`Player.isInvulnerableTo`), so this push is the only one their client gets. **Fix.** - `explosion_hurt_player` now returns the push it gave. - `explosion_hurt_entities` collects one push per guest, including the acting guest in their own turn, the way `wind_knockback` already does for wind bursts. - `server_explode_as` passes those pushes to `lan_explode`, and through its guest-turn deferral (`creatures.lan_explosions`). `send_explosion` puts each player's push into their packet. **Hurt players are left out of the packet.** A player whose velocity a hurt marked still gets the whole velocity, push included, from the motion packet once their server copy has travelled (`Entity.markHurt`, then `ServerEntity.sendChanges`). In vanilla that later motion packet replaces whatever the explosion packet added, so the end result is the same. Adding the push to their packet as well would push them twice in a guest's own turn, because that motion packet goes out before the deferred explosion packet. (On the vanilla server, a survival player at the harness's crystal spot gets `explode push -0.64755 0.52452 0.00000` and then `motion self -0.64756 0.44613 0.00000`, and the motion packet sets their velocity.) **Found while testing, not fixed here:** someone else's crystal still doesn't push or hurt the players around it. While a player's turn runs, the host is taken out of `Game`, so `explosion_hurt_entities` reaches only that player. In game, a survival host standing 3 blocks from a crystal a LAN guest hit took no damage and didn't move. That needs a separate change to how a turn reaches the other players. ## 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 - `ServerExplosion.hurtEntities`: `pushFromExplosion`, then `hitPlayers.put(player, knockback)` unless `isSpectator()`, or `isCreative() && getAbilities().flying`. - `ServerLevel.explode`: `ClientboundExplodePacket(..., Optional.ofNullable(hitPlayers.get(player)), ...)` to each player within 64 blocks. - `ClientPacketListener.handleExplosion`: `playerKnockback` is added to the player's motion. - `Player.isInvulnerableTo`: a creative player takes no explosion damage, so there is no `markHurt` and no motion packet. **Harness:** `tools/test_server_knockback_parity.py` has two new cases, `crystal-creative` (Bob in creative hits an end crystal 2 blocks away) and `tnt-creative` (primed TNT goes off 2 blocks from Bob in creative). `KnockbackClient` now records the push each `ClientboundExplodePacket` carries. Both cases match vanilla exactly: Bob gets `explode push -0.64755 0.52452 0.00000` and `-0.59146 0.46097 0.00000`, with no motion packet, and Alice's packet carries no push. ## Self-check `tools/pr_ready.py` doesn't run on Windows, so I ran these by hand: - `cargo fmt --all -- --check`: clean. - `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - `cargo build --profile fast -p horizon-client --bins`: ok. - `python tools/test_server_knockback_parity.py`: - **Code reverted, harness kept:** fails with "2 cases differ". ``` crystal-creative: -Bob explode push -0.64755 0.52452 0.00000 +Bob explode push none tnt-creative: -Bob explode push -0.59146 0.46097 0.00000 +Bob motion self -0.59147 0.38259 0.00000 +Bob explode push none ``` - **With the fix:** `server knockback: 22 of 23 cases identical`. The one left is `pvp-mace`, which is already in KNOWN. - **In game, server thread, creative.** I hit an end crystal 3 blocks away: - Before: position `531.5 -> 531.5`, velocity unchanged. - After: pushed to `528.50`, with a first-tick velocity of `(0, -0.048, -0.27)`. - TNT 2 blocks away pushed the player before the fix too, but through the motion packet that replaces the client's velocity. It now pushes through the explosion packet (`531.5 -> 528.59`). - **LAN guest, creative, with the fix.** A second game joined over LAN and hit a crystal, and was pushed `555.5 -> 552.50`. The before case for a guest is the harness's `crystal-creative` above: its players are guests on the same server code. ## Screenshots Before: after hitting the crystal, the creative player is still standing at the edge of the crater. After: the blast throws the player about 3 blocks back, and the crater is in the distance. 🤖 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:19 +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#5397
No description provided.