aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-21 22:10:31 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-21 22:10:31 -0500
commit5dd4c58fea97d5df8f18c099701b7034ae8939f5 (patch)
tree3ef3b740b4942a5786b428b402b68edb672aef0f /src/main/java
parentb56cf5d2a1aa1864b43acae69aedde676afafd57 (diff)
downloadDulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.tar.gz
DulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.tar.bz2
DulkirMod-Fabric-5dd4c58fea97d5df8f18c099701b7034ae8939f5.zip
more work on Chat parsing and Sound handling
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java
index 867f91b..ce84582 100644
--- a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java
@@ -1,20 +1,19 @@
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.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SoundSystem.class)
public class SoundSystemMixin {
- @Inject(method = "play(Lnet/minecraft/client/sound/SoundInstance;)V",
- at = @At("HEAD"), cancellable = true)
- public void onSound(SoundInstance sound, CallbackInfo ci) {
- if (new PlaySoundEvent(sound).post())
- ci.cancel();
+ @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());
}
}