Skip to content

Commit

Permalink
Add 0.00000000001 to "ambit radius squared" calculations to account f…
Browse files Browse the repository at this point in the history
…or potential machine precision errors when calculating the ambit at specific angles.
  • Loading branch information
garyyo authored and SamsTheNerd committed Nov 5, 2024
1 parent d5920c9 commit 3f6b70e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
if (sentinel != null
&& sentinel.extendsRange()
&& caster.level().dimension() == sentinel.dimension()
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,13 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
if (sentinel != null
&& sentinel.extendsRange()
&& this.caster.level().dimension() == sentinel.dimension()
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS
// adding 0.00000000001 to avoid machine precision errors at specific angles
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
) {
return true;
}

return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS;
return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS + 0.00000000001;
}

@Override
Expand Down

0 comments on commit 3f6b70e

Please sign in to comment.