diff options
Diffstat (limited to 'src/main/java/moe/nea/ultranotifier/mixin/ChatHudMessageAdded.java')
-rw-r--r-- | src/main/java/moe/nea/ultranotifier/mixin/ChatHudMessageAdded.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/ultranotifier/mixin/ChatHudMessageAdded.java b/src/main/java/moe/nea/ultranotifier/mixin/ChatHudMessageAdded.java new file mode 100644 index 0000000..b8239d3 --- /dev/null +++ b/src/main/java/moe/nea/ultranotifier/mixin/ChatHudMessageAdded.java @@ -0,0 +1,41 @@ +package moe.nea.ultranotifier.mixin; + +import moe.nea.ultranotifier.ChatLineAddedEvent; +import moe.nea.ultranotifier.UltraNotifierEvents; +import net.minecraft.client.gui.hud.ChatHud; +//#if MC > 11404 +import net.minecraft.client.gui.hud.MessageIndicator; +import net.minecraft.network.message.MessageSignatureData; +//#endif +import net.minecraft.text.Text; +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( + ChatHud.class +) +public class ChatHudMessageAdded { + @Inject( +//#if MC <= 11404 +//$$ method = "printChatMessageWithOptionalDeletion", +//#else + method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", +//#endif + at = @At("HEAD"), cancellable = true) + private void onAddMessage( + Text message, +//#if MC <= 11404 +//$$ int chatLineId, +//#else + MessageSignatureData signatureData, MessageIndicator indicator, +//#endif + CallbackInfo ci + ) { + if (UltraNotifierEvents.post(new ChatLineAddedEvent()).isCancelled()) { + ci.cancel(); + } + } + +} |