调整武器站跟随炮塔旋转逻辑

This commit is contained in:
Atsuihsio 2025-03-10 03:40:23 +08:00
parent 59e59cf285
commit d85b7150f3

View file

@ -590,24 +590,26 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
private void turretAngle() { private void turretAngle() {
Entity driver = this.getFirstPassenger(); 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; diffY = Mth.wrapDegrees(turretAngle - getTurretYRot() + 0.05f);
float diffX; diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot());
diffY = Mth.wrapDegrees(turretAngle - getTurretYRot() + 0.05f); turretTurnSound(diffX, diffY, 0.95f);
diffX = Mth.wrapDegrees(driver.getXRot() - this.getTurretXRot());
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); this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, -5, 5), -30f, 4f));
float max = 5 + (float) (isInWater() && !onGround() ? 2.5 : 6) * entityData.get(DELTA_ROT); 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)); } else {
this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, min, max)); turretRot = 0;
turretRot = Mth.clamp(0.9f * diffY, min, max); }
} }
private void gunnerAngle() { private void gunnerAngle() {