33import com .ishland .fabric .rsls .common .SoundManagerDuck ;
44import com .ishland .fabric .rsls .mixin .access .ISoundExecutor ;
55import com .ishland .fabric .rsls .mixin .access .ISoundSystem ;
6+ import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
7+ import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
8+ import com .llamalad7 .mixinextras .injector .wrapoperation .WrapOperation ;
69import net .minecraft .client .sound .SoundExecutor ;
710import net .minecraft .client .sound .SoundInstance ;
811import net .minecraft .client .sound .SoundInstanceListener ;
1114import net .minecraft .client .sound .TickableSoundInstance ;
1215import net .minecraft .client .sound .WeightedSoundSet ;
1316import net .minecraft .sound .SoundCategory ;
14- import net .minecraft .util .Identifier ;
1517import org .jetbrains .annotations .Nullable ;
1618import org .spongepowered .asm .mixin .Final ;
1719import org .spongepowered .asm .mixin .Mixin ;
1820import org .spongepowered .asm .mixin .Mutable ;
1921import org .spongepowered .asm .mixin .Shadow ;
2022import org .spongepowered .asm .mixin .Unique ;
2123import org .spongepowered .asm .mixin .injection .At ;
24+ import org .spongepowered .asm .mixin .injection .Coerce ;
2225import org .spongepowered .asm .mixin .injection .Inject ;
2326import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
2427
@@ -31,7 +34,7 @@ public abstract class MixinSoundManager implements SoundManagerDuck {
3134 @ Shadow @ Final private SoundSystem soundSystem ;
3235
3336 @ Mutable
34- @ Shadow @ Final private Map <Identifier , WeightedSoundSet > sounds ;
37+ @ Shadow @ Final private Map <? , WeightedSoundSet > sounds ;
3538
3639 @ Shadow public abstract void playNextTick (TickableSoundInstance sound );
3740
@@ -47,8 +50,6 @@ public abstract class MixinSoundManager implements SoundManagerDuck {
4750
4851 @ Shadow public abstract void unregisterListener (SoundInstanceListener listener );
4952
50- @ Shadow public abstract void stopSounds (@ Nullable Identifier id , @ Nullable SoundCategory soundCategory );
51-
5253 @ Shadow public abstract void reloadSounds ();
5354
5455 @ Inject (method = "<init>" , at = @ At ("RETURN" ), remap = false )
@@ -118,11 +119,12 @@ private void onUnregisterListener(SoundInstanceListener listener, CallbackInfo c
118119 }
119120 }
120121
121- @ Inject (method = "stopSounds " , at = @ At ( "HEAD" ), cancellable = true )
122- private void onStopSounds (Identifier id , SoundCategory soundCategory , CallbackInfo ci ) {
122+ @ WrapMethod (method = { "stop(Lnet/minecraft/resources/ResourceLocation;Lnet/minecraft/sounds/SoundSource;)V " , "stopSounds" } )
123+ private void onStopSounds (@ Coerce Object id , SoundCategory soundCategory , Operation < Void > original ) {
123124 if (rsls$shouldRunOffthread ()) {
124- ci .cancel ();
125- ((ISoundSystem ) this .soundSystem ).getTaskQueue ().execute (() -> this .stopSounds (id , soundCategory ));
125+ ((ISoundSystem ) this .soundSystem ).getTaskQueue ().execute (() -> original .call (id , soundCategory ));
126+ } else {
127+ original .call (id , soundCategory );
126128 }
127129 }
128130
0 commit comments