diff options
author | Ronald Inglett <71849533+inglettronald@users.noreply.github.com> | 2023-06-29 17:32:17 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-29 17:32:17 -0500 |
commit | 903bf5ffb8675e9b907b91d1adadb04d68ef40c3 (patch) | |
tree | cd3eb0615037b8650f469f194a28fcac88cf6adb /src/main/java/com | |
parent | 1fc9c0f7fe8a998e4cf04c8b498abc643533d6e7 (diff) | |
parent | 5f0fd39650659010a23055c11eae66fb3ffb2ad0 (diff) | |
download | DulkirMod-Fabric-903bf5ffb8675e9b907b91d1adadb04d68ef40c3.tar.gz DulkirMod-Fabric-903bf5ffb8675e9b907b91d1adadb04d68ef40c3.tar.bz2 DulkirMod-Fabric-903bf5ffb8675e9b907b91d1adadb04d68ef40c3.zip |
Merge pull request #2 from IlmarsXd/master
Fix NPE with PlaySoundEvent
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java index ce84582..3f4c0af 100644 --- a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java @@ -1,19 +1,18 @@ package com.dulkirfabric.mixin; import com.dulkirfabric.events.PlaySoundEvent; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.client.sound.SoundInstance; import net.minecraft.client.sound.SoundSystem; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(SoundSystem.class) public class SoundSystemMixin { - @ModifyExpressionValue(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundInstance;canPlay()Z")) - public boolean onSound(boolean original, SoundInstance sound) { - return !(new PlaySoundEvent(sound).post()); + @Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundInstance;getSound()Lnet/minecraft/client/sound/Sound;"), cancellable = true) + public void onSound(SoundInstance sound, CallbackInfo ci) { + if (new PlaySoundEvent(sound).post()) ci.cancel(); } } |