修复了两处可能导致NaN的问题
This commit is contained in:
parent
3d067fdbf4
commit
4814ff605a
2 changed files with 4 additions and 3 deletions
|
@ -456,7 +456,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit
|
||||||
barrelLookAt = new Vec3(lookingAt.getX() - barrelRootPos.x, lookingAt.getEyeY() - barrelRootPos.y, lookingAt.getZ() - barrelRootPos.z);
|
barrelLookAt = new Vec3(lookingAt.getX() - barrelRootPos.x, lookingAt.getEyeY() - barrelRootPos.y, lookingAt.getZ() - barrelRootPos.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.entityData.set(OFFSET_ANGLE, (float)calculateAngle(entity.getViewVector(1),barrelLookAt));
|
this.entityData.set(OFFSET_ANGLE, (float) calculateAngle(entity.getViewVector(1), barrelLookAt));
|
||||||
|
|
||||||
float passengerY = entity.getYHeadRot();
|
float passengerY = entity.getYHeadRot();
|
||||||
|
|
||||||
|
@ -485,7 +485,7 @@ public class AnnihilatorEntity extends Entity implements GeoEntity, ICannonEntit
|
||||||
double startLength = passenger.length();
|
double startLength = passenger.length();
|
||||||
double endLength = barrel.length();
|
double endLength = barrel.length();
|
||||||
if (startLength > 0.0D && endLength > 0.0D) {
|
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 {
|
} else {
|
||||||
return 0.0D;
|
return 0.0D;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.atsuishio.superbwarfare.tools;
|
package com.atsuishio.superbwarfare.tools;
|
||||||
|
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.LivingEntity;
|
import net.minecraft.world.entity.LivingEntity;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
@ -50,7 +51,7 @@ public class SeekTool {
|
||||||
double startLength = start.length();
|
double startLength = start.length();
|
||||||
double endLength = end.length();
|
double endLength = end.length();
|
||||||
if (startLength > 0.0D && endLength > 0.0D) {
|
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 {
|
} else {
|
||||||
return 0.0D;
|
return 0.0D;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue