修复了两处可能导致NaN的问题
This commit is contained in:
parent
3d067fdbf4
commit
4814ff605a
2 changed files with 4 additions and 3 deletions
|
@ -485,7 +485,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit
|
|||
double startLength = passenger.length();
|
||||
double endLength = barrel.length();
|
||||
if (startLength > 0.0D && endLength > 0.0D) {
|
||||
return Math.toDegrees(Math.acos(passenger.dot(barrel) / (startLength * endLength)));
|
||||
return Math.toDegrees(Math.acos(Mth.clamp(passenger.dot(barrel) / (startLength * endLength), -1, 1)));
|
||||
} else {
|
||||
return 0.0D;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.atsuishio.superbwarfare.tools;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
|
@ -50,7 +51,7 @@ public class SeekTool {
|
|||
double startLength = start.length();
|
||||
double endLength = end.length();
|
||||
if (startLength > 0.0D && endLength > 0.0D) {
|
||||
return Math.toDegrees(Math.acos(start.dot(end) / (startLength * endLength)));
|
||||
return Math.toDegrees(Math.acos(Mth.clamp(start.dot(end) / (startLength * endLength), -1, 1)));
|
||||
} else {
|
||||
return 0.0D;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue