From 308bc50bd8353694040bd79d3014adc4c44305ad Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sat, 24 May 2025 17:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=9F=B3=E6=95=88=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/atsuishio/superbwarfare/Mod.java | 20 ++------------- .../client/sound/ModSoundInstances.java | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/sound/ModSoundInstances.java diff --git a/src/main/java/com/atsuishio/superbwarfare/Mod.java b/src/main/java/com/atsuishio/superbwarfare/Mod.java index 96c5fec16..7c4471212 100644 --- a/src/main/java/com/atsuishio/superbwarfare/Mod.java +++ b/src/main/java/com/atsuishio/superbwarfare/Mod.java @@ -3,22 +3,15 @@ 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.FastProjectileSoundInstance; -import com.atsuishio.superbwarfare.client.sound.VehicleFireSoundInstance; -import com.atsuishio.superbwarfare.client.sound.VehicleSoundInstance; +import com.atsuishio.superbwarfare.client.sound.ModSoundInstances; 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.projectile.FastThrowableProjectile; -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.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; @@ -130,16 +123,7 @@ 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)); - MobileVehicleEntity.swimSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(vehicle)); - - A10Entity.fireSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(vehicle)); - Hpj11Entity.fireSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(vehicle)); - - FastThrowableProjectile.flySound = entity -> Minecraft.getInstance().getSoundManager().play(new FastProjectileSoundInstance.FlySound(entity)); - FastThrowableProjectile.nearFlySound = entity -> Minecraft.getInstance().getSoundManager().play(new FastProjectileSoundInstance.NearFlySound(entity)); + event.enqueueWork(ModSoundInstances::init); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/client/sound/ModSoundInstances.java b/src/main/java/com/atsuishio/superbwarfare/client/sound/ModSoundInstances.java new file mode 100644 index 000000000..9cc615295 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/sound/ModSoundInstances.java @@ -0,0 +1,25 @@ +package com.atsuishio.superbwarfare.client.sound; + +import com.atsuishio.superbwarfare.entity.projectile.FastThrowableProjectile; +import com.atsuishio.superbwarfare.entity.vehicle.A10Entity; +import com.atsuishio.superbwarfare.entity.vehicle.Hpj11Entity; +import com.atsuishio.superbwarfare.entity.vehicle.base.MobileVehicleEntity; +import net.minecraft.client.Minecraft; +import net.neoforged.api.distmarker.Dist; +import net.neoforged.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class ModSoundInstances { + + public static void init() { + MobileVehicleEntity.trackSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.TrackSound(vehicle)); + MobileVehicleEntity.engineSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.EngineSound(vehicle)); + MobileVehicleEntity.swimSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleSoundInstance.SwimSound(vehicle)); + + A10Entity.fireSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.A10FireSound(vehicle)); + Hpj11Entity.fireSound = vehicle -> Minecraft.getInstance().getSoundManager().play(new VehicleFireSoundInstance.HPJ11CloseFireSound(vehicle)); + + FastThrowableProjectile.flySound = entity -> Minecraft.getInstance().getSoundManager().play(new FastProjectileSoundInstance.FlySound(entity)); + FastThrowableProjectile.nearFlySound = entity -> Minecraft.getInstance().getSoundManager().play(new FastProjectileSoundInstance.NearFlySound(entity)); + } +}