Skip to content

Commit 3f6b70e

Browse files
garyyoSamsTheNerd
authored andcommitted
Add 0.00000000001 to "ambit radius squared" calculations to account for potential machine precision errors when calculating the ambit at specific angles.
1 parent d5920c9 commit 3f6b70e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/CircleCastEnv.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
139139
if (sentinel != null
140140
&& sentinel.extendsRange()
141141
&& caster.level().dimension() == sentinel.dimension()
142-
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS
142+
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
143143
) {
144144
return true;
145145
}

Common/src/main/java/at/petrak/hexcasting/api/casting/eval/env/PlayerBasedCastEnv.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ public boolean isVecInRangeEnvironment(Vec3 vec) {
178178
if (sentinel != null
179179
&& sentinel.extendsRange()
180180
&& this.caster.level().dimension() == sentinel.dimension()
181-
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS
181+
// adding 0.00000000001 to avoid machine precision errors at specific angles
182+
&& vec.distanceToSqr(sentinel.position()) <= SENTINEL_RADIUS * SENTINEL_RADIUS + 0.00000000001
182183
) {
183184
return true;
184185
}
185186

186-
return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS;
187+
return vec.distanceToSqr(this.caster.position()) <= AMBIT_RADIUS * AMBIT_RADIUS + 0.00000000001;
187188
}
188189

189190
@Override

0 commit comments

Comments
 (0)