@@ -297,19 +297,22 @@ func (lt *ProjectileBehaviour) tickMovement(e *Ent, tx *world.Tx) (*Movement, tr
297
297
if ! mgl64 .FloatEqual (end .Sub (pos ).LenSqr (), 0 ) {
298
298
if hit , ok = trace .Perform (pos , end , tx , e .H ().Type ().BBox (e ).Grow (1.0 ), lt .ignores (e )); ok {
299
299
if r , ok := hit .(trace.BlockResult ); ok {
300
- // Undo the gravity because the velocity as a result of gravity
301
- // at the point of collision should be 0.
302
- vel [1 ] = (vel [1 ] + lt .mc .Gravity ) / (1 - lt .mc .Drag )
303
- x , y , z := vel .Mul (lt .conf .BlockCollisionVelocityMultiplier ).Elem ()
304
- // Calculate multipliers for all coordinates: 1 for the ones that
305
- // weren't on the same axis as the one collided with, -1 for the one
306
- // that was on that axis to deflect the projectile.
307
- mx , my , mz := hit .Face ().Axis ().Vec3 ().Mul (- 2 ).Add (mgl64.Vec3 {1 , 1 , 1 }).Elem ()
308
-
309
- vel = mgl64.Vec3 {x * mx , y * my , z * mz }
300
+ resultPos := r .BlockPosition ()
301
+ if h , ok := tx .Block (resultPos ).(block.ProjectileHitter ); ok {
302
+ h .ProjectileHit (resultPos , tx , e , r .Face ())
303
+ }
304
+ // Check that the block hit was not set to air by a block.ProjectileHitter.
305
+ if _ , ok := tx .Block (resultPos ).(block.Air ); ! ok {
306
+ // Undo the gravity because the velocity as a result of gravity
307
+ // at the point of collision should be 0.
308
+ vel [1 ] = (vel [1 ] + lt .mc .Gravity ) / (1 - lt .mc .Drag )
309
+ x , y , z := vel .Mul (lt .conf .BlockCollisionVelocityMultiplier ).Elem ()
310
+ // Calculate multipliers for all coordinates: 1 for the ones that
311
+ // weren't on the same axis as the one collided with, -1 for the one
312
+ // that was on that axis to deflect the projectile.
313
+ mx , my , mz := hit .Face ().Axis ().Vec3 ().Mul (- 2 ).Add (mgl64.Vec3 {1 , 1 , 1 }).Elem ()
310
314
311
- if h , ok := tx .Block (r .BlockPosition ()).(block.ProjectileHitter ); ok {
312
- h .ProjectileHit (r .BlockPosition (), tx , e , r .Face ())
315
+ vel = mgl64.Vec3 {x * mx , y * my , z * mz }
313
316
}
314
317
} else {
315
318
vel = zeroVec3
0 commit comments