From f4d0dd52bd5294d39236885958e91052039f384a Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Mon, 5 May 2025 23:11:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E5=8A=A0=E5=85=A5=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E9=9F=B3=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/ClientVehicleSoundsInstance.java | 46 +++++++++++++++++++ .../superbwarfare/entity/TargetEntity.java | 2 +- .../entity/vehicle/A10Entity.java | 5 +- .../entity/vehicle/Tom6Entity.java | 6 +-- .../superbwarfare/mixins/CameraMixin.java | 7 --- 5 files changed, 53 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/ClientVehicleSoundsInstance.java diff --git a/src/main/java/com/atsuishio/superbwarfare/client/ClientVehicleSoundsInstance.java b/src/main/java/com/atsuishio/superbwarfare/client/ClientVehicleSoundsInstance.java new file mode 100644 index 000000000..c74f3db75 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/ClientVehicleSoundsInstance.java @@ -0,0 +1,46 @@ +package com.atsuishio.superbwarfare.client; + +import com.atsuishio.superbwarfare.entity.vehicle.Tom6Entity; +import net.minecraft.client.resources.sounds.AbstractTickableSoundInstance; +import net.minecraft.client.resources.sounds.SoundInstance; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.sounds.SoundSource; +import net.minecraft.util.Mth; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class ClientVehicleSoundsInstance extends AbstractTickableSoundInstance { + private final Tom6Entity tom6Entity; + + public ClientVehicleSoundsInstance(Tom6Entity pTom6Entity) { + super(SoundEvents.ELYTRA_FLYING, SoundSource.PLAYERS, SoundInstance.createUnseededRandom()); + this.tom6Entity = pTom6Entity; + this.looping = true; + this.delay = 0; + this.volume = 0.0F; + this.x = pTom6Entity.getX(); + this.y = pTom6Entity.getY(); + this.z = pTom6Entity.getZ(); + } + + public void tick() { + if (this.tom6Entity.isRemoved()) { + this.stop(); + } else { + this.x = tom6Entity.getX(); + this.y = tom6Entity.getY(); + this.z = tom6Entity.getZ(); + float $$0 = (float) tom6Entity.getDeltaMovement().horizontalDistance(); + if ($$0 >= 0.01F) { + this.pitch = Mth.clamp(this.pitch + 0.0025F, 0.0F, 1.0F); + this.volume = Mth.lerp(Mth.clamp($$0, 0.0F, 0.5F), 0.0F, 0.7F); + } else { + this.pitch = 0.0F; + this.volume = 0.0F; + } + + } + } +} + diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java index ccb3cb327..b016a086b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/TargetEntity.java @@ -116,7 +116,7 @@ public class TargetEntity extends LivingEntity implements GeoEntity { if (sourceEntity instanceof Player player) { player.displayClientMessage(Component.translatable("tips.superbwarfare.target.down", - FormatTool.format1D((entity.position()).distanceTo((sourceEntity.position()))), "m"), true); + FormatTool.format1D(entity.position().distanceTo(sourceEntity.position())), "m"), true); SoundTool.playLocalSound(player, ModSounds.TARGET_DOWN.get(), 1, 1); targetEntity.entityData.set(DOWN_TIME, 40); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java index ea56c82ff..82636ae69 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.GunGrenadeEntity; import com.atsuishio.superbwarfare.entity.projectile.MelonBombEntity; import com.atsuishio.superbwarfare.entity.projectile.MortarShellEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; @@ -45,7 +46,7 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.animation.AnimatableManager; import software.bernie.geckolib.util.GeckoLibUtil; -public class A10Entity extends MobileVehicleEntity implements GeoEntity { +public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity { private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private float yRotSync; private boolean fly; @@ -340,7 +341,7 @@ public class A10Entity extends MobileVehicleEntity implements GeoEntity { float x = 0f; float y = 0.1f; - float z = 3.8494875f; + float z = 3.95f; // TODO 正确调整乘客位置 y += (float) passenger.getVehicleAttachmentPoint(this).y; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java index cc5176bcd..089c1280b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java @@ -156,9 +156,9 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity { this.setXRot(Mth.clamp(this.getXRot() + 0.1f, -89, 89)); } } else if (passenger instanceof Player player) { - if (level().isClientSide && this.getEnergy() > 0) { - level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.forwardInputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1.2f), false); - } +// if (level().isClientSide && this.getEnergy() > 0) { +// level().playLocalSound(this.getX(), this.getY() + this.getBbHeight() * 0.5, this.getZ(), this.getEngineSound(), this.getSoundSource(), Math.min((this.forwardInputDown ? 7.5f : 5f) * 2 * Mth.abs(this.entityData.get(POWER)), 0.25f), (random.nextFloat() * 0.1f + 1.2f), false); +// } if (forwardInputDown && getEnergy() > 0) { this.consumeEnergy(VehicleConfig.TOM_6_ENERGY_COST.get()); diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java index 86d45f7a2..ac4783afe 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/CameraMixin.java @@ -152,13 +152,6 @@ public abstract class CameraMixin { return; } -// if (player.getVehicle() instanceof A10Entity vehicle && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) { -// setRotation(Mth.lerp(partialTicks, vehicle.yRotO, vehicle.getYRot()), Mth.lerp(partialTicks, vehicle.xRotO, vehicle.getXRot())); -// setPosition(Mth.lerp(partialTicks, player.xo, player.getX()), Mth.lerp(partialTicks, player.yo + player.getEyeHeight(), player.getEyeY()), Mth.lerp(partialTicks, player.zo, player.getZ())); -// info.cancel(); -// return; -// } - if (player.getVehicle() instanceof VehicleEntity vehicle && vehicle instanceof CannonEntity cannon && (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON || ClientEventHandler.zoomVehicle)) { setRotation(Mth.lerp(partialTicks, player.yRotO, player.getYRot()), Mth.lerp(partialTicks, player.xRotO, player.getXRot())); if (!(cannon instanceof AnnihilatorEntity) && ClientEventHandler.zoomVehicle) {