From d85b7150f324d81858da96c4b8bc6bb2d0972a8f Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Mon, 10 Mar 2025 03:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=AD=A6=E5=99=A8=E7=AB=99?= =?UTF-8?q?=E8=B7=9F=E9=9A=8F=E7=82=AE=E5=A1=94=E6=97=8B=E8=BD=AC=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vehicle/Yx100Entity.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index b168c0734..e0dee92b6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -590,24 +590,26 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti private void turretAngle() { Entity driver = this.getFirstPassenger(); - if (!(driver instanceof Player)) return; + if (driver != null) { + float turretAngle = -Mth.wrapDegrees(driver.getYHeadRot() - this.getYRot()); - float turretAngle = -Mth.wrapDegrees(driver.getYHeadRot() - this.getYRot()); + float diffY; + float diffX; - float diffY; - float diffX; + diffY = Mth.wrapDegrees(turretAngle - getTurretYRot() + 0.05f); + diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot()); - diffY = Mth.wrapDegrees(turretAngle - getTurretYRot() + 0.05f); - diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot()); + turretTurnSound(diffX, diffY, 0.95f); - turretTurnSound(diffX, diffY, 0.95f); + float min = -5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); + float max = 5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); - float min = -5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); - float max = 5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); - - this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, -5, 5), -30f, 4f)); - this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, min, max)); - turretRot = Mth.clamp(0.9f * diffY, min, max); + this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, -5, 5), -30f, 4f)); + this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, min, max)); + turretRot = Mth.clamp(0.9f * diffY, min, max); + } else { + turretRot = 0; + } } private void gunnerAngle() {