From 78f5f7b94bdc48c3395ef17f30022b8cd653a776 Mon Sep 17 00:00:00 2001 From: David Cole <40234707+DavidArthurCole@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:31:23 -0400 Subject: Feature: Add option to maintain sound levels during SoundUtils usage (#2129) --- .../at/hannibal2/skyhanni/config/features/misc/MiscConfig.java | 6 ++++++ src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2') diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java index 5dc2aa5a0..cc606e7aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java @@ -276,4 +276,10 @@ public class MiscConfig { @Accordion @Expose public HideFarEntitiesConfig hideFarEntities = new HideFarEntitiesConfig(); + + @Expose + @ConfigOption(name = "Maintain Volume During Warnings", desc = "Do not change game volume levels when warning sounds are played.") + @ConfigEditorBoolean + @FeatureToggle + public boolean maintainGameVolume = false; } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt index 423747b79..70e6242c6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt @@ -22,7 +22,9 @@ object SoundUtils { Minecraft.getMinecraft().addScheduledTask { val gameSettings = Minecraft.getMinecraft().gameSettings val oldLevel = gameSettings.getSoundLevel(SoundCategory.PLAYERS) - gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f) + if (!SkyHanniMod.feature.misc.maintainGameVolume) { + gameSettings.setSoundLevel(SoundCategory.PLAYERS, 1f) + } try { Minecraft.getMinecraft().soundHandler.playSound(this) } catch (e: Exception) { @@ -39,7 +41,9 @@ object SoundUtils { "soundLocation" to this.soundLocation ) } finally { - gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel) + if (!SkyHanniMod.feature.misc.maintainGameVolume) { + gameSettings.setSoundLevel(SoundCategory.PLAYERS, oldLevel) + } } } } -- cgit