Skip to content

fix: fireball and explosion knockback vector direction calculation - #160

Open
GamingOP69 wants to merge 3 commits into
Wind-Development:masterfrom
GamingOP69:fix/explosion-knockback
Open

fix: fireball and explosion knockback vector direction calculation#160
GamingOP69 wants to merge 3 commits into
Wind-Development:masterfrom
GamingOP69:fix/explosion-knockback

Conversation

@GamingOP69

Copy link
Copy Markdown

Summary

This PR fixes two bugs in Explosion.java:

  1. Inverted fireball knockback vector calculations when explosion yield is small.
  2. Knockback distance check being clipped by a static 64.0D cap instead of scaling with actual blast size.

Problem & Root Cause

  • When calculating explosion knockback for smaller yield explosions (such as small fireballs or custom explosion sizes < 2.0), d13 = d12 / d0 computed an inverted vector direction that caused entities to be pulled inward toward the blast center rather than repelled outward.
  • Large explosions (with radius > 8 blocks) had their knockback clipped prematurely due to a hardcoded d0 < 64.0D distance check, ignoring the actual dynamic blast radius (f3 * 2.0F).

Solution

  • Corrected the vector normalization math in Explosion.java so knockback direction is always calculated outward from the epicenter regardless of yield size.
  • Replaced the hardcoded 64.0D distance check with (f3 * f3) dynamic radius squared check.
  • Added ExplosionKnockbackTest and ExplosionKnockbackRegressionTest unit tests to verify knockback vectors across various explosion sizes.

@kalibrieren

Copy link
Copy Markdown
Contributor

why do all these PRs have // WindSpigot - GamingOP69? just do // WindSpigot or if you really want credit // GamingOP69 not both at once

@GamingOP69

Copy link
Copy Markdown
Author

why do all these PRs have // WindSpigot - GamingOP69? just do // WindSpigot or if you really want credit // GamingOP69 not both at once

it is not a big deal bro ..

@GamingOP69

GamingOP69 commented Aug 19, 2026

Copy link
Copy Markdown
Author

@windcolor-dev can you review all my PRs?

@kalibrieren

Copy link
Copy Markdown
Contributor

why do all these PRs have // WindSpigot - GamingOP69? just do // WindSpigot or if you really want credit // GamingOP69 not both at once

it is not a big deal bro ..

it's just a rule that you don't do both. either // WindSpigot or // GamingOP69.
// WindSpigot - GamingOP69 would just be a comment by WindSpigot saying GamingOP69

@kalibrieren

Copy link
Copy Markdown
Contributor

@windcolor-dev can you review all my PRs?

he will eventually. let him take his time

@windcolor-dev

Copy link
Copy Markdown
Member

why do all these PRs have // WindSpigot - GamingOP69? just do // WindSpigot or if you really want credit // GamingOP69 not both at once

it is not a big deal bro ..

it's just a rule that you don't do both. either // WindSpigot or // GamingOP69. // WindSpigot - GamingOP69 would just be a comment by WindSpigot saying GamingOP69

If you can, please adjust your comments accordingly.

Also, please explain the PR in your own words, without AI so it's more clear/accurate

@GamingOP69

Copy link
Copy Markdown
Author

why do all these PRs have // WindSpigot - GamingOP69? just do // WindSpigot or if you really want credit // GamingOP69 not both at once

it is not a big deal bro ..

it's just a rule that you don't do both. either // WindSpigot or // GamingOP69. // WindSpigot - GamingOP69 would just be a comment by WindSpigot saying GamingOP69

If you can, please adjust your comments accordingly.

Also, please explain the PR in your own words, without AI so it's more clear/accurate

ok I will do it when I am back home.

@GamingOP69

Copy link
Copy Markdown
Author

Ok done 👍

@GamingOP69

Copy link
Copy Markdown
Author

@windcolor-dev

@windcolor-dev

Copy link
Copy Markdown
Member

Please also rewrite the PR description in your own words

}

public void affectEntities(List<Entity> list, Vec3D vec3d, float f3) {
// WindSpigot start - GamingOP69 - fix fireball & explosion knockback direction and radius scaling

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// WindSpigot start - GamingOP69 - fix fireball & explosion knockback direction and radius scaling
// WindSpigot start - fix fireball & explosion knockback direction and radius scaling

private void processEntityKnockback(Entity entity, double d7, double finalD, double finalD1, double finalD11, float f3, double d12) {
double d13 = (1.0D - d7) * d12;
if (d13 < 0.0D) {
return; // WindSpigot - GamingOP69 - prevent negative knockback multiplier

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return; // WindSpigot - GamingOP69 - prevent negative knockback multiplier
return; // WindSpigot - prevent negative knockback multiplier

@kalibrieren

Copy link
Copy Markdown
Contributor

please don't do // WindSpigot when it's a internal class from WindSpigot. also don't wrap entire methods with // WindSpigot start when you haven't changed the entire method :)

@kalibrieren

Copy link
Copy Markdown
Contributor

please don't do // WindSpigot when it's a internal class from WindSpigot. also don't wrap entire methods with // WindSpigot start when you haven't changed the entire method :)

@GamingOP69 i made suggestions on your PRs where you can apply these fixes directly

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.

3 participants