优化坦克武器站旋转逻辑
This commit is contained in:
parent
7e4f5eaf9c
commit
0562fcd527
2 changed files with 14 additions and 12 deletions
|
@ -66,7 +66,7 @@ public class Yx100Renderer extends GeoEntityRenderer<Yx100Entity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equals("jiqiang")) {
|
if (name.equals("jiqiang")) {
|
||||||
bone.setRotY(Mth.lerp(partialTick, animatable.gunYRotO, animatable.getGunYRot()) * Mth.DEG_TO_RAD - (animatable.getNthEntity(1) == null ? 0 : Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * Mth.DEG_TO_RAD));
|
bone.setRotY(Mth.lerp(partialTick, animatable.gunYRotO, animatable.getGunYRot()) * Mth.DEG_TO_RAD - Mth.lerp(partialTick, animatable.turretYRotO, animatable.getTurretYRot()) * Mth.DEG_TO_RAD);
|
||||||
}
|
}
|
||||||
if (name.equals("qiangguan")) {
|
if (name.equals("qiangguan")) {
|
||||||
bone.setRotX(-Mth.lerp(partialTick, animatable.gunXRotO, animatable.getGunXRot()) * Mth.DEG_TO_RAD);
|
bone.setRotX(-Mth.lerp(partialTick, animatable.gunXRotO, animatable.getGunXRot()) * Mth.DEG_TO_RAD);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
public float turretXRot;
|
public float turretXRot;
|
||||||
public float turretYRotO;
|
public float turretYRotO;
|
||||||
public float turretXRotO;
|
public float turretXRotO;
|
||||||
|
public float turretRot;
|
||||||
public float gunYRot;
|
public float gunYRot;
|
||||||
public float gunXRot;
|
public float gunXRot;
|
||||||
public float gunYRotO;
|
public float gunYRotO;
|
||||||
|
@ -596,24 +596,26 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
this.setTurretXRot(Mth.clamp(this.getTurretXRot() + Mth.clamp(0.95f * diffX, -5, 5), -30f, 4f));
|
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));
|
this.setTurretYRot(this.getTurretYRot() + Mth.clamp(0.9f * diffY, min, max));
|
||||||
|
turretRot = Mth.clamp(0.9f * diffY, min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gunnerAngle() {
|
private void gunnerAngle() {
|
||||||
Entity gunner = this.getNthEntity(1);
|
Entity gunner = this.getNthEntity(1);
|
||||||
if (!(gunner instanceof Player)) return;
|
|
||||||
|
|
||||||
float gunAngle = -Mth.wrapDegrees(gunner.getYHeadRot() - this.getYRot());
|
float diffY = 0;
|
||||||
|
float diffX = 0;
|
||||||
|
float speed = 1;
|
||||||
|
|
||||||
float diffY;
|
if (gunner instanceof Player) {
|
||||||
float diffX;
|
float gunAngle = -Mth.wrapDegrees(gunner.getYHeadRot() - this.getYRot());
|
||||||
|
diffY = Mth.wrapDegrees(gunAngle - getGunYRot());
|
||||||
diffY = Mth.wrapDegrees(gunAngle - getGunYRot());
|
diffX = Mth.wrapDegrees(gunner.getXRot() - this.getGunXRot());
|
||||||
diffX = Mth.wrapDegrees(gunner.getXRot() - this.getGunXRot());
|
turretTurnSound(diffX, diffY, 0.95f);
|
||||||
|
speed = 0;
|
||||||
turretTurnSound(diffX, diffY, 0.95f);
|
}
|
||||||
|
|
||||||
this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.95f * diffX, -10, 10), -60f, 12.5f));
|
this.setGunXRot(Mth.clamp(this.getGunXRot() + Mth.clamp(0.95f * diffX, -10, 10), -60f, 12.5f));
|
||||||
this.setGunYRot(this.getGunYRot() + Mth.clamp(0.9f * diffY, -15, 15));
|
this.setGunYRot(this.getGunYRot() + Mth.clamp(0.9f * diffY, -15, 15) + speed * turretRot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue