Skip to content

Commit f526ab3

Browse files
committed
Add second handler for toast sound, close #51
1 parent 6bff0e0 commit f526ab3

File tree

6 files changed

+33
-1
lines changed

6 files changed

+33
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.5.15
4+
5+
- Fixed 'Silent Toast' option not working on 1.21.5
6+
37
## 1.5.14
48

59
- Fixed partial paths in sprites.json being overwritten by defaults
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
# https://docs.neoforged.net/docs/advanced/accesstransformers
2+
public net.minecraft.client.gui.components.toasts.ToastManager$ToastInstance
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
accessWidener v2 named
22
# https://fabricmc.net/wiki/tutorial:accesswideners
3+
accessible class net/minecraft/client/gui/components/toasts/ToastManager$ToastInstance

fabric/src/main/java/com/github/scotsguy/nowplaying/mixin/MixinToastInstance.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636

3737
@Mixin(ToastManager.class)
3838
public class MixinToastInstance {
39+
@WrapOperation(
40+
method = "method_61991",
41+
at = @At(
42+
value = "INVOKE",
43+
target = "Lnet/minecraft/client/gui/components/toasts/Toast$Visibility;playSound(Lnet/minecraft/client/sounds/SoundManager;)V"
44+
)
45+
)
46+
void silenceWooshSound(Toast.Visibility instance, SoundManager handler, Operation<Void> original, @Local(argsOnly = true) ToastManager.ToastInstance<?> toastInstance) {
47+
if (!(toastInstance.getToast() instanceof NowPlayingToast && Config.options().silenceWoosh)) {
48+
original.call(instance, handler);
49+
}
50+
}
51+
3952
@WrapOperation(
4053
method = "method_61992",
4154
at = @At(

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Neo/Forge version ranges: https://maven.apache.org/enforcer/enforcer-rules/versionRanges.html
44

55
# Project
6-
mod_version=1.5.14
6+
mod_version=1.5.15
77
mod_group=com.github.scotsguy
88
mod_id=now-playing
99
mod_name=Now Playing

neoforge/src/main/java/com/github/scotsguy/nowplaying/mixin/MixinToastInstance.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,19 @@
3636

3737
@Mixin(ToastManager.class)
3838
public class MixinToastInstance {
39+
@WrapOperation(
40+
method = "lambda$update$0",
41+
at = @At(
42+
value = "INVOKE",
43+
target = "Lnet/minecraft/client/gui/components/toasts/Toast$Visibility;playSound(Lnet/minecraft/client/sounds/SoundManager;)V"
44+
)
45+
)
46+
void silenceWooshSound(Toast.Visibility instance, SoundManager handler, Operation<Void> original, @Local(argsOnly = true) ToastManager.ToastInstance<?> toastInstance) {
47+
if (!(toastInstance.getToast() instanceof NowPlayingToast && Config.options().silenceWoosh)) {
48+
original.call(instance, handler);
49+
}
50+
}
51+
3952
@WrapOperation(
4053
method = "lambda$update$1",
4154
at = @At(

0 commit comments

Comments
 (0)