From 4814ff605a56726c22f06e04ad384e3607d6e9e1 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Wed, 11 Dec 2024 20:58:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E4=B8=A4=E5=A4=84?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AF=BC=E8=87=B4NaN=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java | 4 ++-- src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java index a1a163091..1657771e1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/AnnihilatorEntity.java @@ -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); } - 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(); @@ -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; } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java index 0df31388b..40d06dfc1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/SeekTool.java @@ -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; }