[GH-ISSUE #6203] Native mods: a projectile's impact, ProjectileImpactEvent #2011

Closed
opened 2026-11-02 15:51:21 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @levzzz5154 on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6203

Originally assigned to: @levzzz5154 on GitHub.

🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally.

Part of #4953 ("Entity: tick, mount, size, projectile impact").

A native mod that guards an area (a force field), lets arrows through a ghost, or catches projectiles in a machine has no point to hear a projectile's impact and say no to it. native_living_incoming_damage comes only after the hit is decided, too late to stop a pearl teleporting, a potion bursting or an arrow sticking in a block.

Vanilla and NeoForge 26.3:

  • Vanilla finds the impact in each projectile's own tick: ThrowableProjectile.tick and AbstractHurtingProjectile.tick (a getHitResultOnMoveVector, then hitTargetOrDeflectSelf), AbstractArrow.stepMoveAndHit (the block's or the nearest entity's hit, in a loop), ShulkerBullet.tick, LlamaSpit.tick, FireworkRocketEntity.tick, FishingHook.tick.
  • NeoForge posts ProjectileImpactEvent (cancellable; the projectile and the HitResult) from each of those, before hitTargetOrDeflectSelf. Its contract: when canceled the impact is not processed and the projectile keeps flying; what then happens to it is up to the mod.

Horizon flies its projectiles (arrows, tridents, snowballs, eggs, pearls, potions, fireballs, wither skulls, wind charges, llama spit, shulker bullets) in one place, tick_projectiles (game/creatures.rs). The hit is found inside the library's tick (Projectile::tick, arrows::tick), which has no Game, so the first step is:

  • native_projectile_impact(dimension, projectile, kind, owner, entity, entity_kind, block, face, at, canceled): one hook, server-side, told for each impact once the tick has found it. The mod sees the projectile's id and type, its owner, and what it hit: an entity (id and type) or a block (position and face normal), and the point. It sets canceled.
  • A canceled impact flies the tick again from the projectile's state before it, through what it hit (Projectile::tick_through, arrows::tick_through): an arrow stops where it would have hit and flies on, the others go the whole way of their motion. Nothing of the hit happens (no damage, sound, block reaction, sticking, teleport or burst).

Not in this step, listed here for the following ones: fireworks rockets (game/fireworks.rs), fishing bobbers, a breeze's deflection, a hit on a wind charge, and the client's copies of projectiles. API from a fragment.

Originally created by @levzzz5154 on GitHub (Nov 1, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/6203 Originally assigned to: @levzzz5154 on GitHub. > 🤖 Filed by levzzz5154's AI agent (Claude Code, Claude Sonnet 5.5), not by levzzz5154 personally. Part of #4953 ("Entity: tick, mount, size, projectile impact"). A native mod that guards an area (a force field), lets arrows through a ghost, or catches projectiles in a machine has no point to hear a projectile's impact and say no to it. `native_living_incoming_damage` comes only after the hit is decided, too late to stop a pearl teleporting, a potion bursting or an arrow sticking in a block. Vanilla and NeoForge 26.3: - Vanilla finds the impact in each projectile's own tick: `ThrowableProjectile.tick` and `AbstractHurtingProjectile.tick` (a `getHitResultOnMoveVector`, then `hitTargetOrDeflectSelf`), `AbstractArrow.stepMoveAndHit` (the block's or the nearest entity's hit, in a loop), `ShulkerBullet.tick`, `LlamaSpit.tick`, `FireworkRocketEntity.tick`, `FishingHook.tick`. - NeoForge posts `ProjectileImpactEvent` (cancellable; the projectile and the `HitResult`) from each of those, before `hitTargetOrDeflectSelf`. Its contract: when canceled the impact is not processed and the projectile keeps flying; what then happens to it is up to the mod. Horizon flies its projectiles (arrows, tridents, snowballs, eggs, pearls, potions, fireballs, wither skulls, wind charges, llama spit, shulker bullets) in one place, `tick_projectiles` (game/creatures.rs). The hit is found inside the library's tick (`Projectile::tick`, `arrows::tick`), which has no `Game`, so the first step is: - `native_projectile_impact(dimension, projectile, kind, owner, entity, entity_kind, block, face, at, canceled)`: one hook, server-side, told for each impact once the tick has found it. The mod sees the projectile's id and type, its owner, and what it hit: an entity (id and type) or a block (position and face normal), and the point. It sets `canceled`. - A canceled impact flies the tick again from the projectile's state before it, through what it hit (`Projectile::tick_through`, `arrows::tick_through`): an arrow stops where it would have hit and flies on, the others go the whole way of their motion. Nothing of the hit happens (no damage, sound, block reaction, sticking, teleport or burst). Not in this step, listed here for the following ones: fireworks rockets (`game/fireworks.rs`), fishing bobbers, a breeze's deflection, a hit on a wind charge, and the client's copies of projectiles. API from a fragment.
Author
Owner

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

/claim

<!-- gh-comment-id:6561827579 --> @levzzz5154 commented on GitHub (Nov 1, 2026): /claim
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#2011
No description provided.