From 60b1a6d181140285acea44558198e4c454e7aad0 Mon Sep 17 00:00:00 2001 From: ImToggle <98242902+ImToggle@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:00:53 +0800 Subject: [PATCH] fixed chat peek notification --- .../mixin/ChatPeekMixin_SkyHanni.java | 2 +- .../chatting/mixin/GuiNewChatMixin.java | 5 ----- .../mixin/GuiNewChatMixin_ChatPeek.java | 20 +++++++++++++++++++ src/main/resources/mixins.chatting.json | 1 + 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatPeek.java diff --git a/src/main/java/org/polyfrost/chatting/mixin/ChatPeekMixin_SkyHanni.java b/src/main/java/org/polyfrost/chatting/mixin/ChatPeekMixin_SkyHanni.java index c8604aa..c065b94 100644 --- a/src/main/java/org/polyfrost/chatting/mixin/ChatPeekMixin_SkyHanni.java +++ b/src/main/java/org/polyfrost/chatting/mixin/ChatPeekMixin_SkyHanni.java @@ -18,7 +18,7 @@ public class ChatPeekMixin_SkyHanni { private static long chatting$lastNotify = System.currentTimeMillis(); @Dynamic("SkyHanni") - @Inject(method = "peek", at = @At("HEAD"), cancellable = true, remap = false) + @Inject(method = "peek", at = @At("RETURN"), cancellable = true) private static void cancel(CallbackInfoReturnable cir) { if (!ChattingConfig.INSTANCE.getChatPeek() && cir.getReturnValue()) { if (System.currentTimeMillis() - chatting$lastNotify >= 1000) { diff --git a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java index 121ddc4..7555aee 100644 --- a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java +++ b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin.java @@ -305,11 +305,6 @@ private void drawPost(int updateCounter, CallbackInfo ci) { */ - @Inject(method = "getChatOpen", at = @At("HEAD"), cancellable = true) - private void chatPeek(CallbackInfoReturnable cir) { - cir.setReturnValue(mc.currentScreen instanceof GuiChat || Chatting.INSTANCE.getPeeking()); - } - @Inject(method = "drawChat", at = @At("RETURN")) private void checkStuff(int j2, CallbackInfo ci) { if (!chatting$chatCheck && chatting$isHovering) { diff --git a/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatPeek.java b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatPeek.java new file mode 100644 index 0000000..e65a9ed --- /dev/null +++ b/src/main/java/org/polyfrost/chatting/mixin/GuiNewChatMixin_ChatPeek.java @@ -0,0 +1,20 @@ +package org.polyfrost.chatting.mixin; + +import cc.polyfrost.oneconfig.libs.universal.UMinecraft; +import net.minecraft.client.gui.GuiChat; +import net.minecraft.client.gui.GuiNewChat; +import org.polyfrost.chatting.Chatting; +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.CallbackInfoReturnable; + +@Mixin(value = GuiNewChat.class, priority = 1100) +public class GuiNewChatMixin_ChatPeek { + + @Inject(method = "getChatOpen", at = @At("HEAD"), cancellable = true) + private void chatPeek(CallbackInfoReturnable cir) { + cir.setReturnValue(UMinecraft.getMinecraft().currentScreen instanceof GuiChat || Chatting.INSTANCE.getPeeking()); + } + +} \ No newline at end of file diff --git a/src/main/resources/mixins.chatting.json b/src/main/resources/mixins.chatting.json index c9c7e55..f7e4385 100644 --- a/src/main/resources/mixins.chatting.json +++ b/src/main/resources/mixins.chatting.json @@ -17,6 +17,7 @@ "GuiNewChatAccessor", "GuiNewChatMixin", "GuiNewChatMixin_ChatHeight", + "GuiNewChatMixin_ChatPeek", "GuiNewChatMixin_ChatSearching", "GuiNewChatMixin_ChatTabs", "GuiNewChatMixin_Movable",