From 9ce69634081cf4434f1677220d32bb93bf4ce1a1 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Tue, 24 Jun 2025 01:17:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AE=80=E5=8C=96=E7=82=AE=E5=A1=94=E5=92=8C?= =?UTF-8?q?=E6=AD=A6=E5=99=A8=E7=AB=99=E7=9A=84=E8=87=AA=E5=8A=A8=E7=9E=84?= =?UTF-8?q?=E5=87=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/vehicle/Yx100Entity.java | 17 +++-------------- .../entity/vehicle/base/VehicleEntity.java | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 20 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 92f85fb38..255cbc102 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -333,18 +333,6 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.refreshDimensions(); } -// public void autoAimTest() { -// Entity target = EntityFindUtil.findEntity(level(), entityData.get(LAST_ATTACKER_UUID)); -// if (target != null) { -// Matrix4f transform = getGunTransform(1); -// Vector4f worldPosition = transformPosition(transform, 0, -0.25f, 0); -// Vec3 shootVec = new Vec3(getGunnerVector(1).x, getGunnerVector(1).y + 0.01f, getGunnerVector(1).z); -// Vec3 shootPos = new Vec3(worldPosition.x, worldPosition.y, worldPosition.z); -// Vec3 targetVec = shootPos.vectorTo(target.getBoundingBox().getCenter()); -// passengerWeaponAutoAimFormVector(15, 15 , -10, 45, shootVec, targetVec); -// } -// } - @Override public void terrainCompact(float w, float l) { if (onGround()) { @@ -827,8 +815,9 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z)); } - public Vec3 getGunnerVector(float pPartialTicks) { - Matrix4f transform = getGunnerBarrelTransform(pPartialTicks); + @Override + public Vec3 getBarrelVec(float ticks) { + Matrix4f transform = getGunnerBarrelTransform(ticks); Vector4f rootPosition = transformPosition(transform, 0, 0, 0); Vector4f targetPosition = transformPosition(transform, 0, 0, 1); return new Vec3(rootPosition.x, rootPosition.y, rootPosition.z).vectorTo(new Vec3(targetPosition.x, targetPosition.y, targetPosition.z)); 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 907a8775d..cfa7a2419 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 @@ -892,9 +892,10 @@ public abstract class VehicleEntity extends Entity { } } - public void turretAutoAimFormVector(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)); + public void turretAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec) { + //shootVec是需要让炮塔以这个角度发射的向量 + float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(shootVec) + getYRotFromVector(getBarrelVec(1))); + float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(shootVec) + getXRotFromVector(getBarrelVec(1))); this.turretTurnSound(diffX, diffY, 0.95f); @@ -911,9 +912,10 @@ public abstract class VehicleEntity extends Entity { turretYRotLock = Mth.clamp(0.9f * diffY, min, max); } - public void passengerWeaponAutoAimFormVector(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)); + public void passengerWeaponAutoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec) { + //shootVec是需要让炮武器站以这个角度发射的向量 + float diffY = (float) Mth.wrapDegrees(-getYRotFromVector(shootVec) + getYRotFromVector(getGunnerVector(1))); + float diffX = (float) Mth.wrapDegrees(-getXRotFromVector(shootVec) + getXRotFromVector(getGunnerVector(1))); turretTurnSound(diffX, diffY, 0.95f); @@ -1134,6 +1136,10 @@ public abstract class VehicleEntity extends Entity { return this.calculateViewVector(this.getBarrelXRot(pPartialTicks), this.getBarrelYRot(pPartialTicks)); } + public Vec3 getGunnerVector(float pPartialTicks) { + return this.getViewVector(pPartialTicks); + } + public float getBarrelXRot(float pPartialTicks) { return Mth.lerp(pPartialTicks, turretXRotO - this.xRotO, getTurretXRot() - this.getXRot()); }