From f20aa72fdadd7176d75d7dc925ccb5e5ee18fc0b Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Sat, 1 Feb 2025 16:23:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=87=E6=9E=AA=E5=AF=BC?= =?UTF-8?q?=E5=BC=B9=E5=88=B6=E5=AF=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/JavelinMissileRenderer.java | 9 +-- .../projectile/JavelinMissileEntity.java | 76 +++++++++---------- .../entity/vehicle/Ah6Entity.java | 14 ++-- .../entity/vehicle/Bmp2Entity.java | 10 +++ .../entity/vehicle/ILandArmorEntity.java | 2 + .../entity/vehicle/Lav150Entity.java | 10 +++ .../mixins/MouseHandlerMixin.java | 2 +- 7 files changed, 69 insertions(+), 54 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/JavelinMissileRenderer.java b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/JavelinMissileRenderer.java index 45216a0fd..d8aacb329 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/JavelinMissileRenderer.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/renderer/entity/JavelinMissileRenderer.java @@ -37,13 +37,8 @@ public class JavelinMissileRenderer extends GeoEntityRenderer 3) { - poseStack.mulPose(Axis.YP.rotationDegrees(90 - Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()))); - poseStack.mulPose(Axis.ZP.rotationDegrees(Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot()) - 90)); - } else { - poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90)); - poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot()))); - } + poseStack.mulPose(Axis.YP.rotationDegrees(Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot()) - 90)); + poseStack.mulPose(Axis.ZP.rotationDegrees(90 + Mth.lerp(partialTicks, entityIn.xRotO, entityIn.getXRot()))); super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn); poseStack.popPose(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index a0e0794b9..fb63f81a9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -10,7 +10,6 @@ import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; import com.atsuishio.superbwarfare.tools.*; -import net.minecraft.commands.arguments.EntityAnchorArgument; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.protocol.Packet; @@ -196,16 +195,12 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo if (entity != null) { if (entity.level() instanceof ServerLevel) { this.entityData.set(TARGET_X, (float) entity.getX()); - this.entityData.set(TARGET_Y, (float) entity.getEyeY()); + this.entityData.set(TARGET_Y, (float) entity.getY() + 0.5f * entity.getBbHeight()); this.entityData.set(TARGET_Z, (float) entity.getZ()); if ((!entity.getPassengers().isEmpty() || entity instanceof VehicleEntity) && entity.tickCount %((int)Math.max(0.04 * this.distanceTo(entity),2)) == 0) { entity.level().playSound(null, entity.getOnPos(), entity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.MISSILE_WARNING.get(), SoundSource.PLAYERS, 2, 1f); } } - } else { - this.entityData.set(TARGET_X, (float)(this.getX() + this.getDeltaMovement().scale(10).x)); - this.entityData.set(TARGET_Y, (float)(this.getY() + this.getDeltaMovement().scale(10).y)); - this.entityData.set(TARGET_Z, (float)(this.getZ() + this.getDeltaMovement().scale(10).z)); } @@ -213,7 +208,31 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo double ex = this.entityData.get(TARGET_X); double pz = this.getZ(); double ez = this.entityData.get(TARGET_Z); - boolean dir = Math.sqrt(Math.pow(px - ex, 2) + Math.pow(pz - ez, 2)) < 10; + boolean dir = Math.sqrt(Math.pow(px - ex, 2) + Math.pow(pz - ez, 2)) < 30; + Vec3 targetPos = new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z)); + if (entity != null) { + Vec3 toVec = getEyePosition().vectorTo(targetPos).normalize(); + if (this.tickCount > 3) { + if (entityData.get(TOP)) { + if (!dir) { + Vec3 targetTopPos = new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + Mth.clamp(5 * this.tickCount, 0, 90), this.entityData.get(TARGET_Z)); + Vec3 toTopVec = getEyePosition().vectorTo(targetTopPos).normalize(); + setDeltaMovement(getDeltaMovement().add(toTopVec.scale(0.5))); + } else { + boolean lostTarget = this.getY() < entity.getY(); + if (!lostTarget) { + setDeltaMovement(getDeltaMovement().add(toVec.scale(0.8)).scale(0.95)); + } + } + } else { + boolean lostTarget = (VectorTool.calculateAngle(getDeltaMovement(), toVec) > 80); + if (!lostTarget) { + setDeltaMovement(getDeltaMovement().add(toVec.scale(0.8)).scale(0.9)); + } + } + } + } + if (this.tickCount == 4) { if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { @@ -222,26 +241,7 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo } } - if (this.tickCount > 3) { - if (entityData.get(TOP)) { - if (!dir) { - this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + Mth.clamp(4 * this.tickCount, 0, 90), this.entityData.get(TARGET_Z))); - } else { - this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z))); - this.setDeltaMovement(this.getDeltaMovement().multiply(1.03, 1.03, 1.03)); - } - - } else { - this.look(EntityAnchorArgument.Anchor.EYES, new Vec3(this.entityData.get(TARGET_X), this.entityData.get(TARGET_Y) + (entity instanceof EnderDragon ? -3 : 0), this.entityData.get(TARGET_Z))); - } - } - if (this.tickCount > 4) { - this.setDeltaMovement(new Vec3( - 0.7f * this.getDeltaMovement().x + (dir ? 3 : 1.3f) * this.getLookAngle().x, - 0.7f * this.getDeltaMovement().y + (dir ? 3 : 1.3f) * this.getLookAngle().y, - 0.7f * this.getDeltaMovement().z + (dir ? 3 : 1.3f) * this.getLookAngle().z - )); if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.xo, this.yo, this.zo, 1, 0, 0, 0, 0, true); } @@ -255,6 +255,17 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo } this.discard(); } + + // 控制速度 + if (this.getDeltaMovement().length() < 3) { + this.setDeltaMovement(this.getDeltaMovement().multiply(1.06, 1.06, 1.06)); + } + + if (this.getDeltaMovement().length() > 3.3) { + this.setDeltaMovement(this.getDeltaMovement().multiply(0.9, 0.9, 0.9)); + } + + this.setDeltaMovement(this.getDeltaMovement().multiply(0.96, 0.96, 0.96)); } private void causeExplode(HitResult result) { @@ -275,19 +286,6 @@ public class JavelinMissileEntity extends ThrowableItemProjectile implements Geo ParticleTool.spawnSmallExplosionParticles(this.level(), result.getLocation()); } - private void look(EntityAnchorArgument.Anchor pAnchor, Vec3 pTarget) { - Vec3 vec3 = pAnchor.apply(this); - double d0 = (pTarget.x - vec3.x) * 0.2; - double d1 = (pTarget.y - vec3.y) * 0.2; - double d2 = (pTarget.z - vec3.z) * 0.2; - double d3 = Math.sqrt(d0 * d0 + d2 * d2); - this.setXRot(Mth.wrapDegrees((float) (-(Mth.atan2(d1, d3) * 57.2957763671875)))); - this.setYRot(Mth.wrapDegrees((float) (Mth.atan2(d2, d0) * 57.2957763671875) - 90.0F)); - this.setYHeadRot(this.getYRot()); - this.xRotO = this.getXRot(); - this.yRotO = this.getYRot(); - } - private PlayState movementPredicate(AnimationState event) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.jvm.idle")); } 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 d72daad2a..bb9a136f7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -311,9 +311,9 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) + 2.5f * this.entityData.get(PROPELLER_ROT)); } - this.setYRot(this.getYRot() + Mth.clamp((this.onGround() ? 0.1f : 2f) * diffY * this.entityData.get(PROPELLER_ROT) - 0.5f * this.entityData.get(DELTA_ROT), -8f, 8f)); - this.setXRot(Mth.clamp(this.getXRot() + ((this.onGround()) ? 0 : 1.4f) * diffX * this.entityData.get(PROPELLER_ROT), -80, 80)); - this.setZRot(this.getRoll() - this.entityData.get(DELTA_ROT) + (this.onGround() ? 0 : 0.2f) * diffY * this.entityData.get(PROPELLER_ROT)); + this.setYRot(this.getYRot() + Mth.clamp((this.onGround() ? 0.1f : 2f) * diffY * this.entityData.get(PROPELLER_ROT) - 0.5f * this.entityData.get(DELTA_ROT), -10f, 10f)); + this.setXRot(Mth.clamp(this.getXRot() + ((this.onGround()) ? 0 : 1.5f) * diffX * this.entityData.get(PROPELLER_ROT), -80, 80)); + this.setZRot(this.getRoll() - this.entityData.get(DELTA_ROT) + (this.onGround() ? 0 : 0.25f) * diffY * this.entityData.get(PROPELLER_ROT)); } if (this.level() instanceof ServerLevel) { @@ -327,14 +327,14 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } if (up && engineStartOver) { - this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.002f, 0.12f)); + this.entityData.set(POWER, Math.min(this.entityData.get(POWER) + 0.0032f, 0.12f)); } if (engineStartOver) { if (down) { - this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0015f, this.onGround() ? 0 : 0.0375f)); + this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0022f, this.onGround() ? 0 : 0.01f)); } else if (backInputDown) { - this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0015f, this.onGround() ? 0 : 0.052f)); + this.entityData.set(POWER, Math.max(this.entityData.get(POWER) - 0.0022f, this.onGround() ? 0 : 0.052f)); if (passenger != null) { passenger.setXRot(0.8f * passenger.getXRot()); } @@ -362,7 +362,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * 0.95f); - this.entityData.set(PROPELLER_ROT, Mth.lerp(0.08f, this.entityData.get(PROPELLER_ROT), this.entityData.get(POWER))); + this.entityData.set(PROPELLER_ROT, Mth.lerp(0.5f, 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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 25a710f2f..92a21a651 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -580,6 +580,16 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha return turretYRot; } + @Override + public float turretXRotO() { + return turretXRotO; + } + + @Override + public float turretXRot() { + return turretXRot; + } + @Override public Vec3 getBarrelVec(float ticks) { return getBarrelVector(ticks); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java index 42d79e007..a6cce9812 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/ILandArmorEntity.java @@ -5,5 +5,7 @@ import net.minecraft.world.phys.Vec3; public interface ILandArmorEntity extends IArmedVehicleEntity { float turretYRotO(); float turretYRot(); + float turretXRotO(); + float turretXRot(); Vec3 getBarrelVec(float ticks); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index a85113d15..fe5d798c9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -547,6 +547,16 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC return turretYRot; } + @Override + public float turretXRotO() { + return turretXRotO; + } + + @Override + public float turretXRot() { + return turretXRot; + } + @Override public Vec3 getBarrelVec(float ticks) { return getBarrelVector(ticks); diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java index bfbdca5ce..ac11248b8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/MouseHandlerMixin.java @@ -55,7 +55,7 @@ public class MouseHandlerMixin { } if (player.getVehicle() instanceof Ah6Entity ah6Entity && !ah6Entity.onGround() && ah6Entity.getFirstPassenger() == player) { - return 0.3; + return 0.33; } if (player.getVehicle() instanceof Tom6Entity) {