From b56cf5d2a1aa1864b43acae69aedde676afafd57 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 16 Jun 2023 11:56:00 -0500 Subject: wip --- .../com/dulkirfabric/mixin/SoundSystemMixin.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java (limited to 'src/main/java') diff --git a/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java new file mode 100644 index 0000000..867f91b --- /dev/null +++ b/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java @@ -0,0 +1,20 @@ +package com.dulkirfabric.mixin; + +import com.dulkirfabric.events.PlaySoundEvent; +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; + +@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(); + } +} -- cgit