[PR #7410] [MERGED] Native hook: ExplosionKnockbackEvent (explosion_knockback) #7587

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

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7410
Author: @arismoko
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: v2/ses_01M6EA9PP2BP3SA9FS27G86287-w3-explosion


📝 Commits (10+)

  • e1084ab Add explosion knockback hook for players
  • 355becd Wire explosion knockback for other entities and wind
  • b74cd0c Fix explosion knockback hook contract, dragon and creative flyers
  • 4f3b375 Apply explosion knockback hook after entity damage
  • d926c8e Apply explosion knockback to flying players and dragons
  • 9d24a0e Merge upstream main into w3-explosion
  • 9e2dab8 Merge upstream main into w3-explosion
  • 9de3e58 Dispatch explosion knockback to native mods
  • b75b4d0 Document explosion player context
  • 2f1b035 Merge upstream main into w3-explosion

📊 Changes

7 files changed (+205 additions, -78 deletions)

View changed files

📝 crates/horizon-client/src/game/dragon.rs (+36 -18)
📝 crates/horizon-client/src/game/explosion.rs (+62 -46)
📝 crates/horizon-client/src/game/native_hooks.rs (+25 -0)
📝 crates/horizon-client/src/game/wind.rs (+19 -14)
📝 crates/horizon-client/src/mod_api/generated.rs (+42 -0)
📝 docs/native-mods.md (+4 -0)
➕ tools/native-hook-fragments/explosion_knockback.json (+17 -0)

📄 Description

🤖 Opened by Aria's agent swarm, Dyna, not by Aria.

Part of #4953.

Hook NeoForge 26.3 counterpart Side Contract Vanilla firing point
explosion_knockback ExplosionKnockbackEvent server collect: each mod can change the velocity in turn ServerExplosion.hurtEntities, after damage and velocity calculation, before pushFromExplosion

What changed and why

The hook gives native mods the explosion position, affected blocks, entity and calculated knockback velocity, and applies each mod's changes to the push. Player knockback sent to clients uses the changed value. Wind bursts share the hook. The event is generated from a native-hook fragment. Player events have no entity ID; native_acting_player identifies the swapped-in player.

Coverage is not complete: end crystals have no velocity in Horizon and do not trigger the hook; Horizon removes vulnerable crystals in its special explosion path. Vanilla's EndCrystal.hurtServer removes a vulnerable crystal hit by an explosion without starting a second explosion. Invulnerable crystals can survive. Wind bursts do not reach Horizon's separate dragon or crystal paths; vanilla ServerExplosion.hurtEntities considers eligible entities for wind explosions too. This is an existing wind-entity coverage gap, not a new parity implementation.

Parity fixes

  • Creative flight: vanilla ServerExplosion.hurtEntities calls pushFromExplosion for every eligible entity, but omits a creative flying player only from hitPlayers, which supplies explosion-packet knockback. Horizon previously skipped the push entirely. It now adds the blast velocity to a creative flyer's server-side velocity while still excluding that player from the explosion packet; this changes behavior even without mods.
  • Dragon, items and orbs: the dragon, including while dying, items and experience orbs now receive the hook, as every entity vanilla sends through ServerExplosion.hurtEntities does. An item or orb the blast destroys still fires the hook, but has no push applied.

Overlap: question for review

#7005's listen-only explosion_prime reports the blast before it begins; the existing explosion_detonate lets mods change affected blocks. Neither changes per-entity knockback. Should the three remain separate hooks as proposed?

Tests

Hook How checked
explosion_knockback Integrated server at b75b4d06a1: baseline and replaced TNT knockback on a zombie, plus a survival player. Dedicated server at the same head: joined player, one event per explosion.
Dragon and wind special-entity paths Read against vanilla ServerExplosion.hurtEntities; not separately exercised in game. The missing wind dragon/crystal coverage is noted above.

Tested in game

At b75b4d06a1, a throwaway trait mod logged the hook and, with W3_EXPLOSION_UP=1, replaced the added velocity with [0, 2, 0]. It was built through the launcher with --trust-native-code, using fresh homes and worlds.

  • Integrated server, zombie: in the baseline blast, the zombie moved from y=119 to y=119 with a small horizontal push. With replacement, the same setup launched a normal-AI zombie from y=119 to y=128.51. Each blast logged exactly one hook for the zombie.
  • Integrated server, player: a survival player rose from y=120 to y=135.74 with replacement, and the hook reported the acting player.
  • Dedicated server, player: a joined survival player rose from y=119 to y=134.90. The server logged one player hook for the explosion, with the joined player's identity and no replay duplicate.

The final head, 5494d7fc5e, merges main through f4a9e85d7b. Its added and removed lines against that main are identical to the tested head's against its own base, so the merges change no line of this PR's diff and the in-game result carries over.

The recommended end-to-end route for native mods is horizon-machine-sample. It was used here: a throwaway trait-API bundle built through the launcher at b75b4d06a1.

pr_ready

pr_ready (tools/pr_ready.py --quick --base f4a9e85d7b111c7b6820dfc6949498256dc38524 on dd4facee92d8, against f4a9e85d7b at f4a9e85d7, 13 min 6 s)

Check Result
Scope ✅ 7 files, +205 −78
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 614 passed (1 min 16 s)
rustfmt ✅ (20 s)
clippy ✅ (1 min 16 s)
tests: horizon-client, horizon-client-lib ✅ 2175 passed (9 min 43 s)
doc tests ✅ 0 passed (7 s)
content root tests ➖ content root untouched
mod API up to date ✅ (23 s)
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (--quick): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Dyna.


🔄 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/7410 **Author:** [@arismoko](https://github.com/arismoko) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `v2/ses_01M6EA9PP2BP3SA9FS27G86287-w3-explosion` --- ### 📝 Commits (10+) - [`e1084ab`](https://github.com/horizon-rust/horizon/commit/e1084abe754025ca6fa203ec97b9227f0d379201) Add explosion knockback hook for players - [`355becd`](https://github.com/horizon-rust/horizon/commit/355becd82dd2ed72437af97261e9532067be8430) Wire explosion knockback for other entities and wind - [`b74cd0c`](https://github.com/horizon-rust/horizon/commit/b74cd0c6000c67c0b00a47c271f48849d6191f2b) Fix explosion knockback hook contract, dragon and creative flyers - [`4f3b375`](https://github.com/horizon-rust/horizon/commit/4f3b375d255e6c47f393708759d980d022fdfac7) Apply explosion knockback hook after entity damage - [`d926c8e`](https://github.com/horizon-rust/horizon/commit/d926c8e3f3bd1067dc964d0ddb55bf724a276e79) Apply explosion knockback to flying players and dragons - [`9d24a0e`](https://github.com/horizon-rust/horizon/commit/9d24a0ea5347aa28ec8429e6e9383a1ec474cacd) Merge upstream main into w3-explosion - [`9e2dab8`](https://github.com/horizon-rust/horizon/commit/9e2dab85471deda61d9a5e65dee09835756ffb60) Merge upstream main into w3-explosion - [`9de3e58`](https://github.com/horizon-rust/horizon/commit/9de3e585b09109d436539fa1c328e36d5181c5c2) Dispatch explosion knockback to native mods - [`b75b4d0`](https://github.com/horizon-rust/horizon/commit/b75b4d06a1a4ff210013a5f996178f265af55fcf) Document explosion player context - [`2f1b035`](https://github.com/horizon-rust/horizon/commit/2f1b035fced35ccc31fd97031f8ef4043f917b13) Merge upstream main into w3-explosion ### 📊 Changes **7 files changed** (+205 additions, -78 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/game/dragon.rs` (+36 -18) 📝 `crates/horizon-client/src/game/explosion.rs` (+62 -46) 📝 `crates/horizon-client/src/game/native_hooks.rs` (+25 -0) 📝 `crates/horizon-client/src/game/wind.rs` (+19 -14) 📝 `crates/horizon-client/src/mod_api/generated.rs` (+42 -0) 📝 `docs/native-mods.md` (+4 -0) ➕ `tools/native-hook-fragments/explosion_knockback.json` (+17 -0) </details> ### 📄 Description > 🤖 Opened by Aria's agent swarm, Dyna, not by Aria. Part of #4953. | Hook | NeoForge 26.3 counterpart | Side | Contract | Vanilla firing point | | --- | --- | --- | --- | --- | | `explosion_knockback` | `ExplosionKnockbackEvent` | server | `collect`: each mod can change the velocity in turn | `ServerExplosion.hurtEntities`, after damage and velocity calculation, before `pushFromExplosion` | ## What changed and why The hook gives native mods the explosion position, affected blocks, entity and calculated knockback velocity, and applies each mod's changes to the push. Player knockback sent to clients uses the changed value. Wind bursts share the hook. The event is generated from a native-hook fragment. Player events have no entity ID; `native_acting_player` identifies the swapped-in player. Coverage is not complete: end crystals have no velocity in Horizon and do not trigger the hook; Horizon removes vulnerable crystals in its special explosion path. Vanilla's `EndCrystal.hurtServer` removes a vulnerable crystal hit by an explosion without starting a second explosion. Invulnerable crystals can survive. Wind bursts do not reach Horizon's separate dragon or crystal paths; vanilla `ServerExplosion.hurtEntities` considers eligible entities for wind explosions too. This is an existing wind-entity coverage gap, not a new parity implementation. ## Parity fixes - **Creative flight:** vanilla `ServerExplosion.hurtEntities` calls `pushFromExplosion` for every eligible entity, but omits a creative flying player only from `hitPlayers`, which supplies explosion-packet knockback. Horizon previously skipped the push entirely. It now adds the blast velocity to a creative flyer's server-side velocity while still excluding that player from the explosion packet; this changes behavior even without mods. - **Dragon, items and orbs:** the dragon, including while dying, items and experience orbs now receive the hook, as every entity vanilla sends through `ServerExplosion.hurtEntities` does. An item or orb the blast destroys still fires the hook, but has no push applied. ## Overlap: question for review #7005's listen-only `explosion_prime` reports the blast before it begins; the existing `explosion_detonate` lets mods change affected blocks. Neither changes per-entity knockback. Should the three remain separate hooks as proposed? ## Tests | Hook | How checked | | --- | --- | | `explosion_knockback` | Integrated server at b75b4d06a1: baseline and replaced TNT knockback on a zombie, plus a survival player. Dedicated server at the same head: joined player, one event per explosion. | | Dragon and wind special-entity paths | Read against vanilla `ServerExplosion.hurtEntities`; not separately exercised in game. The missing wind dragon/crystal coverage is noted above. | ## Tested in game At b75b4d06a1, a throwaway trait mod logged the hook and, with `W3_EXPLOSION_UP=1`, replaced the added velocity with `[0, 2, 0]`. It was built through the launcher with `--trust-native-code`, using fresh homes and worlds. - **Integrated server, zombie:** in the baseline blast, the zombie moved from y=119 to y=119 with a small horizontal push. With replacement, the same setup launched a normal-AI zombie from y=119 to y=128.51. Each blast logged exactly one hook for the zombie. - **Integrated server, player:** a survival player rose from y=120 to y=135.74 with replacement, and the hook reported the acting player. - **Dedicated server, player:** a joined survival player rose from y=119 to y=134.90. The server logged one player hook for the explosion, with the joined player's identity and no replay duplicate. The final head, 5494d7fc5e, merges main through f4a9e85d7b. Its added and removed lines against that main are identical to the tested head's against its own base, so the merges change no line of this PR's diff and the in-game result carries over. The recommended end-to-end route for native mods is [horizon-machine-sample](https://github.com/arismoko/horizon-machine-sample). It was used here: a throwaway trait-API bundle built through the launcher at b75b4d06a1. ## pr_ready **pr_ready** (`tools/pr_ready.py --quick --base f4a9e85d7b111c7b6820dfc6949498256dc38524` on dd4facee92d8, against f4a9e85d7b111c7b6820dfc6949498256dc38524 at f4a9e85d7, 13 min 6 s) | Check | Result | | --- | --- | | Scope | ✅ 7 files, +205 −78 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 614 passed (1 min 16 s) | | rustfmt | ✅ (20 s) | | clippy | ✅ (1 min 16 s) | | tests: horizon-client, horizon-client-lib | ✅ 2175 passed (9 min 43 s) | | doc tests | ✅ 0 passed (7 s) | | content root tests | ➖ content root untouched | | mod API up to date | ✅ (23 s) | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (--quick): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with Dyna. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 07:20:22 +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#7587
No description provided.