diff --git a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/Bmp2Model.java b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/Bmp2Model.java index e714de203..effa63a8c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/model/entity/Bmp2Model.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/model/entity/Bmp2Model.java @@ -43,7 +43,6 @@ public class Bmp2Model extends GeoModel { @Override public void setCustomAnimations(Bmp2Entity animatable, long instanceId, AnimationState animationState) { - for (int i = 0; i < 50; i++) { CoreGeoBone trackL = getAnimationProcessor().getBone("trackL" + i); CoreGeoBone trackLRot = getAnimationProcessor().getBone("trackLRot" + i); @@ -56,65 +55,7 @@ public class Bmp2Model extends GeoModel { t -= 100; } - if (t < 37.5) { - trackL.setPosY(0); - trackL.setPosZ(3 * t); - trackLRot.setRotX(0); - } - - if (t >= 37.5 && t < 39.5) { - trackL.setPosY(-(t - 37.5f) * 3 * 0.7071f); - trackL.setPosZ(3 * 37.5f + (t - 37.5f) * 3 * 0.7071f); - trackLRot.setRotX(45 * Mth.DEG_TO_RAD); - } - - if (t >= 39.5 && t < 41.5) { - trackL.setPosY(-5.3f - (t - 39.5f) * 3); - trackL.setPosZ(116); - trackLRot.setRotX(90 * Mth.DEG_TO_RAD); - } - - if (t >= 41.5 && t < 43) { - trackL.setPosY(-11.6f - (t - 41.5f) * 3 * 0.7071f); - trackL.setPosZ(115 - (t - 41.5f) * 3 * 0.7071f); - trackLRot.setRotX(135 * Mth.DEG_TO_RAD); - } - - if (t >= 43 && t < 49.5) { - trackL.setPosY(-15.6f - (t - 43f) * 3 * 0.45f); - trackL.setPosZ(109.5f - (t - 43f) * 3 * 0.75f); - trackLRot.setRotX(150 * Mth.DEG_TO_RAD); - } - - if (t >= 49.5 && t < 76.5) { - trackL.setPosY(-23.5f); - trackL.setPosZ(95f - (t - 49.5f) * 3); - trackLRot.setRotX(180 * Mth.DEG_TO_RAD); - } - - if (t >= 76.5 && t < 83.5) { - trackL.setPosY(-23.5f + (t - 76.5f) * 3 * 0.45f); - trackL.setPosZ(13.5f - (t - 76.5f) * 3 * 0.75f); - trackLRot.setRotX(210 * Mth.DEG_TO_RAD); - } - - if (t >= 83.5 && t < 85.5) { - trackL.setPosY(-12.7f + (t - 83.5f) * 3 * 0.7071f); - trackL.setPosZ(-3.5f - (t - 83.5f) * 3 * 0.7071f); - trackLRot.setRotX(225 * Mth.DEG_TO_RAD); - } - - if (t >= 85.5 && t < 87) { - trackL.setPosY(-9.2f + (t - 85.5f) * 3); - trackL.setPosZ(-6.9f); - trackLRot.setRotX(270 * Mth.DEG_TO_RAD); - } - - if (t >= 87 && t < 89) { - trackL.setPosY(-4.3f + (t - 87f) * 3 * 0.7071f); - trackL.setPosZ(-6.9f + (t - 87f) * 3 * 0.7071f); - trackLRot.setRotX(315 * Mth.DEG_TO_RAD); - } + trackAnimation(trackL, trackLRot, t); float t2 = animatable.getEntityData().get(TRACK_R) + 2 * i; @@ -122,65 +63,69 @@ public class Bmp2Model extends GeoModel { t2 -= 100; } - if (t2 < 37.5) { - trackR.setPosY(0); - trackR.setPosZ(3 * t2); - trackRRot.setRotX(0); - } + trackAnimation(trackR, trackRRot, t2); + } + } - if (t2>= 37.5 && t2< 39.5) { - trackR.setPosY(-(t2- 37.5f) * 3 * 0.7071f); - trackR.setPosZ(3 * 37.5f + (t2- 37.5f) * 3 * 0.7071f); - trackRRot.setRotX(45 * Mth.DEG_TO_RAD); - } + public void trackAnimation(CoreGeoBone track, CoreGeoBone trackRot, float t) { + if (t < 37.5) { + track.setPosY(0); + track.setPosZ(3 * t); + trackRot.setRotX(0); + } - if (t2>= 39.5 && t2< 41.5) { - trackR.setPosY(-5.3f - (t2- 39.5f) * 3); - trackR.setPosZ(116); - trackRRot.setRotX(90 * Mth.DEG_TO_RAD); - } + if (t >= 37.5 && t < 39.5) { + track.setPosY(-(t - 37.5f) * 3 * 0.7071f); + track.setPosZ(3 * 37.5f + (t - 37.5f) * 3 * 0.7071f); + trackRot.setRotX(45 * Mth.DEG_TO_RAD); + } - if (t2>= 41.5 && t2< 43) { - trackR.setPosY(-11.6f - (t2- 41.5f) * 3 * 0.7071f); - trackR.setPosZ(115 - (t2- 41.5f) * 3 * 0.7071f); - trackRRot.setRotX(135 * Mth.DEG_TO_RAD); - } + if (t >= 39.5 && t < 41.5) { + track.setPosY(-5.3f - (t - 39.5f) * 3); + track.setPosZ(116); + trackRot.setRotX(90 * Mth.DEG_TO_RAD); + } - if (t2>= 43 && t2< 49.5) { - trackR.setPosY(-15.6f - (t2- 43f) * 3 * 0.45f); - trackR.setPosZ(109.5f - (t2- 43f) * 3 * 0.75f); - trackRRot.setRotX(150 * Mth.DEG_TO_RAD); - } + if (t >= 41.5 && t < 43) { + track.setPosY(-11.6f - (t - 41.5f) * 3 * 0.7071f); + track.setPosZ(115 - (t - 41.5f) * 3 * 0.7071f); + trackRot.setRotX(135 * Mth.DEG_TO_RAD); + } - if (t2>= 49.5 && t2< 76.5) { - trackR.setPosY(-23.5f); - trackR.setPosZ(95f - (t2- 49.5f) * 3); - trackRRot.setRotX(180 * Mth.DEG_TO_RAD); - } + if (t >= 43 && t < 49.5) { + track.setPosY(-15.6f - (t - 43f) * 3 * 0.45f); + track.setPosZ(109.5f - (t - 43f) * 3 * 0.75f); + trackRot.setRotX(150 * Mth.DEG_TO_RAD); + } - if (t2>= 76.5 && t2< 83.5) { - trackR.setPosY(-23.5f + (t2- 76.5f) * 3 * 0.45f); - trackR.setPosZ(13.5f - (t2- 76.5f) * 3 * 0.75f); - trackRRot.setRotX(210 * Mth.DEG_TO_RAD); - } + if (t >= 49.5 && t < 76.5) { + track.setPosY(-23.5f); + track.setPosZ(95f - (t - 49.5f) * 3); + trackRot.setRotX(180 * Mth.DEG_TO_RAD); + } - if (t2>= 83.5 && t2< 85.5) { - trackR.setPosY(-12.7f + (t2- 83.5f) * 3 * 0.7071f); - trackR.setPosZ(-3.5f - (t2- 83.5f) * 3 * 0.7071f); - trackRRot.setRotX(225 * Mth.DEG_TO_RAD); - } + if (t >= 76.5 && t < 83.5) { + track.setPosY(-23.5f + (t - 76.5f) * 3 * 0.45f); + track.setPosZ(13.5f - (t - 76.5f) * 3 * 0.75f); + trackRot.setRotX(210 * Mth.DEG_TO_RAD); + } - if (t2>= 85.5 && t2< 87) { - trackR.setPosY(-9.2f + (t2- 85.5f) * 3); - trackR.setPosZ(-6.9f); - trackRRot.setRotX(270 * Mth.DEG_TO_RAD); - } + if (t >= 83.5 && t < 85.5) { + track.setPosY(-12.7f + (t - 83.5f) * 3 * 0.7071f); + track.setPosZ(-3.5f - (t - 83.5f) * 3 * 0.7071f); + trackRot.setRotX(225 * Mth.DEG_TO_RAD); + } - if (t2>= 87 && t2< 89) { - trackR.setPosY(-4.3f + (t2- 87f) * 3 * 0.7071f); - trackR.setPosZ(-6.9f + (t2- 87f) * 3 * 0.7071f); - trackRRot.setRotX(315 * Mth.DEG_TO_RAD); - } + if (t >= 85.5 && t < 87) { + track.setPosY(-9.2f + (t - 85.5f) * 3); + track.setPosZ(-6.9f); + trackRot.setRotX(270 * Mth.DEG_TO_RAD); + } + + if (t >= 87 && t < 89) { + track.setPosY(-4.3f + (t - 87f) * 3 * 0.7071f); + track.setPosZ(-6.9f + (t - 87f) * 3 * 0.7071f); + trackRot.setRotX(315 * Mth.DEG_TO_RAD); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index fe810e4f2..f9e7cef01 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -248,7 +248,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli this.setZRot(this.roll * 0.9f); this.setXRot(this.getXRot() * 0.9f); } else { - float f = (float) Mth.clamp(0.945f + 0.02f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); + float f = (float) Mth.clamp(0.875f + 0.02f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90, 0.01, 0.99); this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).scale((this.getXRot() < 0 ? -0.032 : (this.getXRot() > 0 ? 0.032 : 0)) * this.getDeltaMovement().length()))); this.setDeltaMovement(this.getDeltaMovement().multiply(f, 0.95, f)); } @@ -309,10 +309,10 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli if (rightInputDown) { holdTick++; - this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 2f * Math.min(holdTick, 7) * this.entityData.get(PROPELLER_ROT)); + this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) - 2f * Math.min(holdTick, 7) * this.entityData.get(POWER)); } else if (this.leftInputDown) { holdTick++; - this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 2f * Math.min(holdTick, 7) * this.entityData.get(PROPELLER_ROT)); + this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 2f * Math.min(holdTick, 7) * this.entityData.get(POWER)); } else { holdTick = 0; } @@ -333,14 +333,14 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } if (up && engineStartOver) { - this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0032f, 0.12f)); + this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.005f, 0.12f)); } if (engineStartOver) { if (down) { - this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0022f, this.onGround() ? 0 : 0.01f)); + this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0036f, this.onGround() ? 0 : 0.01f)); } else if (backInputDown) { - this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0022f, this.onGround() ? 0 : 0.052f)); + this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0036f, this.onGround() ? 0 : 0.052f)); if (passenger != null) { passenger.setXRot(0.8f * passenger.getXRot()); } @@ -368,7 +368,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.9f); - this.entityData.set(PROPELLER_ROT, Mth.lerp(0.5f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER))); + this.entityData.set(PROPELLER_ROT, Mth.lerp(0.18f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER))); this.setPropellerRot(this.getPropellerRot() + 30 * this.entityData.get(PROPELLER_ROT)); this.entityData.set(PROPELLER_ROT, this.entityData.get(PROPELLER_ROT) * 0.9995f); @@ -376,13 +376,13 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli this.consumeEnergy((int) (VehicleConfig.AH_6_MIN_ENERGY_COST.get() + this.entityData.get(POWER) * ((VehicleConfig.AH_6_MAX_ENERGY_COST.get() - VehicleConfig.AH_6_MIN_ENERGY_COST.get()) / 0.12))); } - setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(PROPELLER_ROT), 0.0f)); + setDeltaMovement(getDeltaMovement().add(0.0f, Math.min(Math.sin((90 - this.getXRot()) * Mth.DEG_TO_RAD), Math.sin((90 + this.getRoll()) * Mth.DEG_TO_RAD)) * this.entityData.get(POWER), 0.0f)); Vector3f direction = getRightDirection().mul(Math.cos((this.getRoll() + 90) * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT)); - setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(backInputDown ? 0.45 : 0.85))); + setDeltaMovement(getDeltaMovement().add(new Vec3(direction.x, direction.y, direction.z).scale(backInputDown ? 0.1 : 2))); Vector3f directionZ = getForwardDirection().mul(-Math.cos((this.getXRot() + 90) * Mth.DEG_TO_RAD) * this.entityData.get(PROPELLER_ROT)); - setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(backInputDown ? 0.1 : 0.35))); + setDeltaMovement(getDeltaMovement().add(new Vec3(directionZ.x, directionZ.y, directionZ.z).scale(backInputDown ? 0.1 : 2))); if (this.entityData.get(POWER) > 0.04f) { engineStartOver = true; diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/EntityMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/EntityMixin.java index a00269470..382ff5eb1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/EntityMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/EntityMixin.java @@ -1,28 +1,24 @@ package com.atsuishio.superbwarfare.mixins; -import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(Entity.class) public class EntityMixin { // TODO 优化后续逻辑 - @Redirect(method = "turn(DD)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setXRot(F)V", ordinal = 1)) - public void turn(Entity instance, float pXRot) { - if (instance instanceof Player player) { - player.setXRot(player.getXRot()); - while (player.getXRot() > 180F) { - player.setXRot(player.getXRot() - 360F); - } - while (player.getYRot() <= -180F) { - player.setXRot(player.getXRot() + 360F); - } - } else { - instance.setXRot(Mth.clamp(instance.getXRot(), -90.0F, 90.0F)); - } - } +// @Redirect(method = "turn(DD)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setXRot(F)V", ordinal = 1)) +// public void turn(Entity instance, float pXRot) { +// if (instance instanceof Player player) { +// player.setXRot(player.getXRot()); +// while (player.getXRot() > 180F) { +// player.setXRot(player.getXRot() - 360F); +// } +// while (player.getYRot() <= -180F) { +// player.setXRot(player.getXRot() + 360F); +// } +// } else { +// instance.setXRot(Mth.clamp(instance.getXRot(), -90.0F, 90.0F)); +// } +// } }