Skip to content

Commit

Permalink
fixed chat peek notification
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed Jul 29, 2024
1 parent f7f8da1 commit 60b1a6d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Boolean> cir) {
if (!ChattingConfig.INSTANCE.getChatPeek() && cir.getReturnValue()) {
if (System.currentTimeMillis() - chatting$lastNotify >= 1000) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,6 @@ private void drawPost(int updateCounter, CallbackInfo ci) {
*/

@Inject(method = "getChatOpen", at = @At("HEAD"), cancellable = true)
private void chatPeek(CallbackInfoReturnable<Boolean> 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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> cir) {
cir.setReturnValue(UMinecraft.getMinecraft().currentScreen instanceof GuiChat || Chatting.INSTANCE.getPeeking());
}

}
1 change: 1 addition & 0 deletions src/main/resources/mixins.chatting.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"GuiNewChatAccessor",
"GuiNewChatMixin",
"GuiNewChatMixin_ChatHeight",
"GuiNewChatMixin_ChatPeek",
"GuiNewChatMixin_ChatSearching",
"GuiNewChatMixin_ChatTabs",
"GuiNewChatMixin_Movable",
Expand Down

0 comments on commit 60b1a6d

Please sign in to comment.