-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from LostLuma/pause-soundmanager
Pause soundmanager instead of stopping all sounds for zero volumes
- Loading branch information
Showing
3 changed files
with
49 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/dynamic_fps/impl/mixin/SoundEngineMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dynamic_fps.impl.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import dynamic_fps.impl.DynamicFPSMod; | ||
import net.minecraft.client.sounds.SoundEngine; | ||
|
||
@Mixin(SoundEngine.class) | ||
public class SoundEngineMixin { | ||
/** | ||
* Cancels playing sounds while we are overwriting the volume to be off. | ||
* | ||
* This is done in favor of actually setting the volume to zero, because it | ||
* Allows pausing and resuming the sound engine without cancelling active sounds. | ||
*/ | ||
@Inject(method = { "play", "playDelayed" }, at = @At("HEAD"), cancellable = true) | ||
private void play(CallbackInfo callbackInfo) { | ||
if (DynamicFPSMod.volumeMultiplier() == 0.0f) { | ||
callbackInfo.cancel(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters