From 0aee8d49cd45b75102e64cc243d82513209ff5f5 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Mon, 23 Jun 2025 01:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A0=94=E7=A9=B6=E5=87=BA=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=90=91=E9=87=8F=E8=A7=A3=E7=AE=97=E7=82=AE=E5=A1=94=E8=A7=92?= =?UTF-8?q?=E5=BA=A6=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vehicle/base/VehicleEntity.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 50e300338..e26b271b0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -889,6 +889,25 @@ public abstract class VehicleEntity extends Entity { } } + public void autoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec, Vec3 targetVec) { + float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(targetVec) + getYRotFromVector(shootVec)); + float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(targetVec) + getXRotFromVector(shootVec)); + + this.turretTurnSound(diffX, diffY, 0.95f); + + if (entityData.get(TURRET_DAMAGED)) { + ySpeed *= 0.2f; + xSpeed *= 0.2f; + } + + float min = -ySpeed + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); + float max = ySpeed + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); + + this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.5f * diffX, -xSpeed, xSpeed), -maxXAngle, -minXAngle)); + this.setTurretYRot(this.getTurretYRot() - Mth.clamp(0.5f * diffY, min, max)); + turretYRotLock = Mth.clamp(0.9f * diffY, min, max); + } + public void gunnerAngle(float ySpeed, float xSpeed) { Entity gunner = this.getNthEntity(1);