Skip to content

Find entity hits of non-arrow projectiles the way vanilla does - #33

Merged
WilyFoxM merged 1 commit into
mainfrom
fix/throwable-entity-hit
Nov 16, 2026
Merged

WilyFoxM merged 1 commit into
mainfrom
fix/throwable-entity-hit

Conversation

@WilyFoxM

Copy link
Copy Markdown
Owner

Problem and resulting behavior

The core used the arrow entity-hit logic for every projectile. Arrows go through ProjectileUtil.getManyEntityHitResult: an exact box hit first, then a hit within the margin that is confirmed by a ray towards the box center and moved onto the real box surface.

Throwables (snowball, egg, ender pearl, potions, bottle o' enchanting), the crossbow firework, the fishing hook and the wind charge don't. In vanilla they go through ProjectileUtil.getHitResultOnMoveVector and getEntityHitResult with computeMargin: each target box inflated by the margin is clipped by the move, the nearest entry point wins (strictly nearer, so the earlier target on a tie), and that entry point is the hit location. There is no ray to the center and no projection onto the surface. This is the same in 26.1.2, 26.2 and 26.3.

What changes for the player, for these projectiles only:

  • The marker on a living target moves to where vanilla puts the hit: up to the margin, 0.3 blocks, out from the hitbox, back along the flight path.
  • In rare cases a hit or a miss changes: a pass within the margin now counts even when a block stands between the path and the target's center, and with two targets close together the one entered first is chosen (the fishing hook used to pick the one whose position was nearest).

Arrows and tridents are unchanged.

ArrowFlight.nearestEntityHit returns the single nearest hit or none, with the same shooter-group and left-owner filter as before; ThrowableFlight, FireworkFlight, FishingHookFlight and WindChargeFlight use it.

Validation performed

  • GitHub checks (build, unit-tests, spotless): pending.
  • Local checks actually run (configuration and result):
    • ./gradlew format build (node 26.2, the only node on main): passed, including the new NearestEntityHitTest (entry into the inflated box, a margin hit without the center ray, the nearest of two overlapping targets, a tie, the shooter filter).
    • Local client run on 26.2 for throws, crossbow (with fireworks), fishing rod and trident: passed. Those runs end on blocks and water, so they check that nothing else moved; they don't exercise an entity hit by these projectiles.
  • Prediction accuracy evidence: none in game for entity hits; the change follows the decompiled vanilla code.

Limits and compatibility

  • Not checked in game against a mob target.
  • PR Build for Minecraft 26.1.x and 26.3 #32 passes a new projectSurface argument to entityHits at these four call sites; whichever lands second needs a small rebase there.

Throwables, fireworks, the fishing hook and the wind charge used the arrow entity-hit logic. In vanilla they go through ProjectileUtil.getHitResultOnMoveVector and getEntityHitResult: each target box inflated by the margin is clipped by the move, the nearest entry wins, and that entry point is the hit location, with no ray to the center and no projection onto the real box. Arrows and tridents keep their own logic.
@WilyFoxM
WilyFoxM merged commit c2fc836 into main Nov 16, 2026
6 checks passed
@WilyFoxM
WilyFoxM deleted the fix/throwable-entity-hit branch November 16, 2026 18:18
This was referenced Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant