From 2d57cc638768b8692bfe6722466fb5905b7bf1ab Mon Sep 17 00:00:00 2001 From: LostLuma Date: Sat, 16 Dec 2023 23:53:31 +0100 Subject: [PATCH 1/2] Fix master volume resetting to 100% when activating focused power state --- .../dynamic_fps/impl/mixin/SoundEngineMixin.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java b/src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java index 6eb53dd7..9f2cdfcc 100644 --- a/src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java +++ b/src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java @@ -15,6 +15,7 @@ import dynamic_fps.impl.DynamicFPSMod; import dynamic_fps.impl.util.duck.DuckSoundEngine; +import net.minecraft.client.Options; import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.client.sounds.ChannelAccess; import net.minecraft.client.sounds.SoundEngine; @@ -22,6 +23,10 @@ @Mixin(SoundEngine.class) public class SoundEngineMixin implements DuckSoundEngine { + @Shadow + @Final + private Options options; + @Shadow private boolean loaded; @@ -97,10 +102,16 @@ private void play(SoundInstance instance, CallbackInfo callbackInfo) { /** * Applies the user's requested volume multiplier to any newly played sounds. */ - @Inject(method = "getVolume", at = @At("RETURN"), cancellable = true) + @Inject(method = "getVolume", at = @At("HEAD"), cancellable = true) private void getVolume(@Nullable SoundSource source, CallbackInfoReturnable callbackInfo) { + float base = 1.0f; + + // Note: The original doesn't consider the user's setting when the source is MASTER + // In vanilla this doesn't matter because it's never called, but we use it when setting the gain if (source != null) { - callbackInfo.setReturnValue(callbackInfo.getReturnValue() * DynamicFPSMod.volumeMultiplier(source)); + base = this.options.getSoundSourceVolume(source); } + + callbackInfo.setReturnValue(base * DynamicFPSMod.volumeMultiplier(source)); } } From e20abd9739aaad30389d23e537b2917da6d01c86 Mon Sep 17 00:00:00 2001 From: LostLuma Date: Sun, 17 Dec 2023 00:01:49 +0100 Subject: [PATCH 2/2] Bump mod version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b066072f..34a6eda2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ org.gradle.parallel = true org.gradle.jvmargs = -Xmx1G # Mod Properties -mod_version = 3.3.0 +mod_version = 3.3.1 maven_group = juliand665 archives_base_name = dynamic-fps