-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: minecart, guardian and other sounds are now silenced properly
- Loading branch information
Showing
3 changed files
with
50 additions
and
43 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
common/src/main/java/gg/meza/client/mixin/AbstractSoundInstanceMixin.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,42 @@ | ||
package gg.meza.client.mixin; | ||
|
||
import gg.meza.SoundsBeGone; | ||
import gg.meza.client.SoundsBeGoneClient; | ||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.sound.AbstractSoundInstance; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Identifier; | ||
import org.spongepowered.asm.mixin.Final; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(AbstractSoundInstance.class) | ||
public class AbstractSoundInstanceMixin { | ||
|
||
@Final | ||
@Shadow | ||
protected Identifier id; | ||
|
||
@Inject( | ||
method = "getVolume()F", | ||
at = @At("HEAD"), | ||
cancellable = true) | ||
private void getVolume(CallbackInfoReturnable<Float> cir) { | ||
|
||
if (SoundsBeGoneClient.config.isSoundDisabled(id.toString())) { | ||
SoundsBeGone.LOGGER.debug("Disabling the sound: {}", id); | ||
SoundsBeGoneClient.telemetry.blockedSound(id.toString()); | ||
cir.setReturnValue(0.0F); | ||
cir.cancel(); | ||
} | ||
|
||
if(MinecraftClient.getInstance().world != null) { | ||
SoundsBeGone.LOGGER.debug("Intercepting the sound: {}", Text.translatable(id.toTranslationKey())); | ||
SoundsBeGoneClient.SoundMap.put(id.toString(), new java.util.Date()); | ||
} | ||
|
||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
common/src/main/java/gg/meza/client/mixin/SoundInterceptorMixin.java
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,10 @@ | ||
{ | ||
"required": true, | ||
"package": "gg.meza.client.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"minVersion": "0.8.4", | ||
"client": [ | ||
"SoundInterceptorMixin" | ||
], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
"required": true, | ||
"package": "gg.meza.client.mixin", | ||
"compatibilityLevel": "JAVA_17", | ||
"minVersion": "0.8.4", | ||
"client": ["AbstractSoundInstanceMixin"], | ||
"injectors": { | ||
"defaultRequire": 1 | ||
} | ||
} |