diff --git a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java index dd53aca41..9bc0f3c5e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/GunEventHandler.java @@ -101,19 +101,21 @@ public class GunEventHandler { ); if (charged.get()) { + float soundRadius = (float) GunsTool.getGunDoubleTag(stack, "SoundRadius"); + SoundEvent sound3p = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_fire_3p")); if (sound3p != null) { - player.playSound(sound3p, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.4f, 1f); + player.playSound(sound3p, soundRadius * 0.4f, 1f); } SoundEvent soundFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_far")); if (soundFar != null) { - player.playSound(soundFar, (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.7f, 1f); + player.playSound(soundFar, soundRadius * 0.7f, 1f); } SoundEvent soundVeryFar = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(ModUtils.MODID, "sentinel_charge_veryfar")); if (soundVeryFar != null) { - player.playSound(soundVeryFar, (float) stack.getOrCreateTag().getDouble("SoundRadius"), 1f); + player.playSound(soundVeryFar, soundRadius, 1f); } return; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java index 46566c186..66cbfccc6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/ShootMessage.java @@ -9,6 +9,7 @@ import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.perk.AmmoPerk; import com.atsuishio.superbwarfare.perk.Perk; import com.atsuishio.superbwarfare.perk.PerkHelper; +import com.atsuishio.superbwarfare.tools.GunsTool; import com.atsuishio.superbwarfare.tools.ParticleTool; import com.atsuishio.superbwarfare.tools.SoundTool; import net.minecraft.core.particles.ParticleTypes; @@ -127,9 +128,11 @@ public class ShootMessage { float pitch = tag.getDouble("heat") <= 40 ? 1 : (float) (1 - 0.025 * Math.abs(40 - tag.getDouble("heat"))); if (!player.level().isClientSide() && player instanceof ServerPlayer) { - player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.2f, pitch); - player.playSound(ModSounds.MINIGUN_FAR.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius") * 0.5f, pitch); - player.playSound(ModSounds.MINIGUN_VERYFAR.get(), (float) stack.getOrCreateTag().getDouble("SoundRadius"), pitch); + float soundRadius = (float) GunsTool.getGunDoubleTag(stack, "SoundRadius"); + + player.playSound(ModSounds.MINIGUN_FIRE_3P.get(), soundRadius * 0.2f, pitch); + player.playSound(ModSounds.MINIGUN_FAR.get(), soundRadius * 0.5f, pitch); + player.playSound(ModSounds.MINIGUN_VERYFAR.get(), soundRadius, pitch); if (perk == ModPerks.BEAST_BULLET.get()) { player.playSound(ModSounds.HENG.get(), 4f, pitch); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java index 1ebfa6c0a..305b68aee 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/GunsTool.java @@ -55,7 +55,7 @@ public class GunsTool { public static void initGun(Level level, ItemStack stack, String location) { if (level.getServer() == null) return; gunsData.get(location).forEach((k, v) -> { - if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight")) { + if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius")) { CompoundTag tag = stack.getOrCreateTag(); CompoundTag data = tag.getCompound("GunData"); data.putDouble(k, v); @@ -69,7 +69,7 @@ public class GunsTool { public static void initCreativeGun(ItemStack stack, String location) { if (gunsData != null && gunsData.get(location) != null) { gunsData.get(location).forEach((k, v) -> { - if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight")) { + if (k.equals("EmptyReloadTime") || k.equals("FireMode") || k.equals("Weight") || k.equals("SoundRadius")) { CompoundTag tag = stack.getOrCreateTag(); CompoundTag data = tag.getCompound("GunData"); data.putDouble(k, v);