diff options
author | David Cole <40234707+DavidArthurCole@users.noreply.github.com> | 2024-06-23 12:31:23 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-23 18:31:23 +0200 |
commit | 78f5f7b94bdc48c3395ef17f30022b8cd653a776 (patch) | |
tree | 88c172ad79fdb814d1f54c1f0af7eff753ac637f /src/main | |
parent | b08dc623846886802093f0a00893ed96dc248ea9 (diff) | |
download | skyhanni-78f5f7b94bdc48c3395ef17f30022b8cd653a776.tar.gz skyhanni-78f5f7b94bdc48c3395ef17f30022b8cd653a776.tar.bz2 skyhanni-78f5f7b94bdc48c3395ef17f30022b8cd653a776.zip |
Feature: Add option to maintain sound levels during SoundUtils usage (#2129)
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java | 6 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/utils/SoundUtils.kt | 8 |
2 files changed, 12 insertions, 2 deletions
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) + } } } } |