From b3f8e7d6712ce0ec76583af338b3daeeadea119f Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sat, 24 May 2025 16:12:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=B0=83=E6=95=B4=E9=9F=B3?= =?UTF-8?q?=E6=95=88=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/atsuishio/superbwarfare/Mod.java | 6 ++++ .../client/sound/ClientSoundHandler.java | 35 ++++++++----------- .../entity/vehicle/Bmp2Entity.java | 15 +++++--- .../entity/vehicle/PrismTankEntity.java | 8 +++-- .../entity/vehicle/Yx100Entity.java | 9 +++-- .../vehicle/base/MobileVehicleEntity.java | 5 ++- .../entity/vehicle/base/TrackEntity.java | 4 --- 7 files changed, 49 insertions(+), 33 deletions(-) delete mode 100644 src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java diff --git a/src/main/java/com/atsuishio/superbwarfare/Mod.java b/src/main/java/com/atsuishio/superbwarfare/Mod.java index 28f5a300f..43c462e23 100644 --- a/src/main/java/com/atsuishio/superbwarfare/Mod.java +++ b/src/main/java/com/atsuishio/superbwarfare/Mod.java @@ -3,14 +3,17 @@ package com.atsuishio.superbwarfare; import com.atsuishio.superbwarfare.api.event.RegisterContainersEvent; import com.atsuishio.superbwarfare.client.MouseMovementHandler; import com.atsuishio.superbwarfare.client.renderer.molang.MolangVariable; +import com.atsuishio.superbwarfare.client.sound.VehicleSoundInstance; import com.atsuishio.superbwarfare.compat.CompatHolder; import com.atsuishio.superbwarfare.compat.clothconfig.ClothConfigHelper; import com.atsuishio.superbwarfare.component.ModDataComponents; import com.atsuishio.superbwarfare.config.ClientConfig; import com.atsuishio.superbwarfare.config.CommonConfig; import com.atsuishio.superbwarfare.config.ServerConfig; +import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.network.NetworkRegistry; +import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.neoforged.api.distmarker.Dist; import net.neoforged.bus.api.IEventBus; @@ -122,6 +125,9 @@ public class Mod { public void onClientSetup(final FMLClientSetupEvent event) { MouseMovementHandler.init(); MolangVariable.register(); + + MobileVehicleEntity.trackSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(vehicle)); + MobileVehicleEntity.engineSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(vehicle, vehicle.getEngineSound())); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/sound/ClientSoundHandler.java b/src/main/java/com/atsuishio/superbwarfare/client/sound/ClientSoundHandler.java index d770a002d..91a6867c3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/sound/ClientSoundHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/sound/ClientSoundHandler.java @@ -1,11 +1,6 @@ package com.atsuishio.superbwarfare.client.sound; -import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.entity.LoudlyEntity; -import com.atsuishio.superbwarfare.entity.vehicle.A10Entity; -import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity; -import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.TrackEntity; import net.minecraft.client.Minecraft; import net.minecraft.world.entity.Entity; import net.neoforged.api.distmarker.Dist; @@ -19,21 +14,21 @@ public class ClientSoundHandler { Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySound(entity)); Minecraft.getInstance().getSoundManager().play(new LoudlyEntitySoundInstance.EntitySoundClose(entity)); } else { - Mod.queueClientWork(60, () -> { - if (entity instanceof MobileVehicleEntity mobileVehicle) { - if (mobileVehicle instanceof TrackEntity) { - Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(mobileVehicle)); - } - if (mobileVehicle instanceof A10Entity) { - Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(mobileVehicle)); - } - if (mobileVehicle instanceof Hpj11Entity) { - Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(mobileVehicle)); - } - Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound())); - Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(mobileVehicle)); - } - }); +// Mod.queueClientWork(60, () -> { +// if (entity instanceof MobileVehicleEntity mobileVehicle) { +// if (mobileVehicle instanceof TrackEntity) { +// Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(mobileVehicle)); +// } +// if (mobileVehicle instanceof A10Entity) { +// Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(mobileVehicle)); +// } +// if (mobileVehicle instanceof Hpj11Entity) { +// Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(mobileVehicle)); +// } +// Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(mobileVehicle, mobileVehicle.getEngineSound())); +// Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(mobileVehicle)); +// } +// }); } } } 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 42fccde63..ee421f563 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -4,7 +4,10 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.AerialBombEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.*; +import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; +import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.SmallCannonShellWeapon; @@ -65,7 +68,7 @@ import java.util.List; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { +public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { public static final EntityDataAccessor CANNON_FIRE_TIME = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_MISSILE = SynchedEntityData.defineId(Bmp2Entity.class, EntityDataSerializers.INT); @@ -189,14 +192,18 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit this.handleAmmo(); } - double fluidFloat; - fluidFloat = 0.052 * getSubmergedHeight(this); + double fluidFloat = 0.052 * getSubmergedHeight(this); this.setDeltaMovement(this.getDeltaMovement().add(0.0, fluidFloat, 0.0)); if (this.onGround()) { float f0 = 0.54f + 0.25f * Mth.abs(90 - (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1))) / 90; this.setDeltaMovement(this.getDeltaMovement().add(this.getViewVector(1).normalize().scale(0.05 * getDeltaMovement().dot(getViewVector(1))))); this.setDeltaMovement(this.getDeltaMovement().multiply(f0, 0.99, f0)); + + // TODO 替换成正确的履带音效播放条件 + if (this.level().isClientSide) { + trackSound.accept(this); + } } else { this.setDeltaMovement(this.getDeltaMovement().multiply(0.99, 0.99, 0.99)); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java index e4346c48c..70fd2f610 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/PrismTankEntity.java @@ -4,7 +4,10 @@ import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.AerialBombEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.*; +import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; +import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.LaserWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.VehicleWeapon; @@ -68,7 +71,8 @@ import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; import static com.atsuishio.superbwarfare.tools.SeekTool.baseFilter; -public class PrismTankEntity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { +// TODO 添加正确的履带音效播放条件 +public class PrismTankEntity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { public static final EntityDataAccessor CANNON_FIRE_TIME = SynchedEntityData.defineId(PrismTankEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LASER_LENGTH = SynchedEntityData.defineId(PrismTankEntity.class, EntityDataSerializers.FLOAT); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index 3951409b0..b1531d2e2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -5,7 +5,10 @@ import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.VehicleConfig; import com.atsuishio.superbwarfare.entity.projectile.AerialBombEntity; import com.atsuishio.superbwarfare.entity.projectile.SwarmDroneEntity; -import com.atsuishio.superbwarfare.entity.vehicle.base.*; +import com.atsuishio.superbwarfare.entity.vehicle.base.ContainerMobileVehicleEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.LandArmorEntity; +import com.atsuishio.superbwarfare.entity.vehicle.base.ThirdPersonCameraPosition; +import com.atsuishio.superbwarfare.entity.vehicle.base.WeaponVehicleEntity; import com.atsuishio.superbwarfare.entity.vehicle.damage.DamageModifier; import com.atsuishio.superbwarfare.entity.vehicle.weapon.CannonShellWeapon; import com.atsuishio.superbwarfare.entity.vehicle.weapon.ProjectileWeapon; @@ -74,7 +77,9 @@ import java.util.List; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; -public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity, TrackEntity { +// TODO 添加正确的履带音效播放条件 +public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEntity, LandArmorEntity, WeaponVehicleEntity { + public static final EntityDataAccessor MG_AMMO = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_AP = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor LOADED_HE = SynchedEntityData.defineId(Yx100Entity.class, EntityDataSerializers.INT); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java index ce66bc40d..ed4590175 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/MobileVehicleEntity.java @@ -51,8 +51,11 @@ import java.util.function.Consumer; import java.util.stream.StreamSupport; public abstract class MobileVehicleEntity extends EnergyVehicleEntity implements ControllableVehicle { - public static Consumer engineSound = e -> { + public static Consumer trackSound = vehicle -> { }; + public static Consumer engineSound = vehicle -> { + }; + public static final EntityDataAccessor CANNON_RECOIL_TIME = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.INT); public static final EntityDataAccessor POWER = SynchedEntityData.defineId(MobileVehicleEntity.class, EntityDataSerializers.FLOAT); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java deleted file mode 100644 index 1c75fd79f..000000000 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/TrackEntity.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.atsuishio.superbwarfare.entity.vehicle.base; - -public interface TrackEntity { -}