Skip to content

Commit

Permalink
Fix changing the master volume override to zero setting all categorie…
Browse files Browse the repository at this point in the history
…s to zero
  • Loading branch information
LostLuma committed Feb 17, 2024
1 parent b6ca2e7 commit 8d35e0e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ public static Screen genConfigScreen(Screen parent) {
volumes.add(
entryBuilder.startIntSlider(
Component.translatable("soundCategory." + name),
(int) (config.volumeMultiplier(source) * 100),
(int) (config.rawVolumeMultiplier(source) * 100),
0, 100
)
.setDefaultValue((int) (standard.volumeMultiplier(source) * 100))
.setDefaultValue((int) (standard.rawVolumeMultiplier(source) * 100))
.setSaveConsumer(value -> config.setVolumeMultiplier(source, value / 100f))
.setTextGetter(ClothConfig::volumeMultiplierMessage)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public void setFrameRateTarget(int value) {
}

public float volumeMultiplier(SoundSource source) {
if (this.getVolumeMultiplier(SoundSource.MASTER) == 0.0f) {
if (this.rawVolumeMultiplier(SoundSource.MASTER) == 0.0f) {
return 0.0f;
} else {
return this.getVolumeMultiplier(source);
return this.rawVolumeMultiplier(source);
}
}

private float getVolumeMultiplier(SoundSource source) {
public float rawVolumeMultiplier(SoundSource source) {
return this.volumeMultipliers.getOrDefault(source, 1.0f);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ private float calculateVolume(SoundInstance instance) {
*/
@Inject(method = { "play", "playDelayed" }, at = @At("HEAD"), cancellable = true)
private void play(SoundInstance instance, CallbackInfo callbackInfo) {
float master = DynamicFPSMod.volumeMultiplier(SoundSource.MASTER);
float source = DynamicFPSMod.volumeMultiplier(instance.getSource());

if (master == 0.0f || source == 0.0f) {
if (DynamicFPSMod.volumeMultiplier(instance.getSource()) == 0.0f) {
callbackInfo.cancel();
}
}
Expand Down

0 comments on commit 8d35e0e

Please sign in to comment.