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 4fbd2614a..92f85fb38 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -333,6 +333,18 @@ 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()) { 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 e26b271b0..2d50f7bd5 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,7 +889,7 @@ public abstract class VehicleEntity extends Entity { } } - public void autoAimFormVector(float ySpeed, float xSpeed, float minXAngle, float maxXAngle, Vec3 shootVec, Vec3 targetVec) { + 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)); @@ -908,6 +908,16 @@ 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)); + + turretTurnSound(diffX, diffY, 0.95f); + + this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.5f * diffX, -xSpeed, xSpeed), -maxXAngle, -minXAngle)); + this.setGunYRot(this.getGunYRot() - Mth.clamp(0.5f * diffY, -ySpeed, ySpeed)); + } + public void gunnerAngle(float ySpeed, float xSpeed) { Entity gunner = this.getNthEntity(1);