aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/dulkirfabric/mixin/SoundSystemMixin.java
blob: 3f4c0af9c2e164cd30e79deb348656fdecc7692a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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(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();
    }
}