aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 12:13:13 -0500
committerWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 12:13:13 -0500
commit1b3670de60500c491e5c61b0d304bcde7e30080f (patch)
tree9657ad419ac41545ea73e11cfea63ff90463f114 /src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
parentf80dad6f297a60f23ca3066742c2df78e3b6fc83 (diff)
downloadChatting-1b3670de60500c491e5c61b0d304bcde7e30080f.tar.gz
Chatting-1b3670de60500c491e5c61b0d304bcde7e30080f.tar.bz2
Chatting-1b3670de60500c491e5c61b0d304bcde7e30080f.zip
various new features
- right click to copy chat message - tooltip text render type - delete button for individual chat lines - copying chat messages now always shows a notification output
Diffstat (limited to 'src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java')
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
index 1774f82..a633a3d 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
@@ -8,10 +8,12 @@ import cc.woverflow.chatting.config.ChattingConfig;
import cc.woverflow.chatting.gui.components.ClearButton;
import cc.woverflow.chatting.gui.components.ScreenshotButton;
import cc.woverflow.chatting.gui.components.SearchButton;
+import cc.woverflow.chatting.hook.ChatLineHook;
import cc.woverflow.chatting.hook.GuiNewChatHook;
import cc.woverflow.chatting.utils.ModCompatHooks;
import com.google.common.collect.Lists;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ChatLine;
import net.minecraft.client.gui.GuiChat;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager;
@@ -85,7 +87,7 @@ public abstract class GuiChatMixin extends GuiScreen {
GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI());
float f = mc.ingameGUI.getChatGUI().getChatScale();
int x = MathHelper.floor_float((float) mouseX / f);
- if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) {
+ if (hook.isHovering() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) {
GuiUtils.drawHoveringText(COPY_TOOLTIP, mouseX, mouseY, width, height, -1, fontRendererObj);
GlStateManager.disableLighting();
}
@@ -101,15 +103,23 @@ public abstract class GuiChatMixin extends GuiScreen {
GuiNewChatHook hook = ((GuiNewChatHook) Minecraft.getMinecraft().ingameGUI.getChatGUI());
float f = mc.ingameGUI.getChatGUI().getChatScale();
int x = MathHelper.floor_float((float) mouseX / f);
- if (hook.shouldCopy() && (hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) {
- Transferable message = hook.getChattingChatComponent(Mouse.getY());
- if (message == null) return;
- try {
- Toolkit.getDefaultToolkit().getSystemClipboard().setContents(message, null);
- } catch (Exception e) {
- e.printStackTrace();
+ if (hook.isHovering()) {
+ if (((hook.getRight() + ModCompatHooks.getXOffset() + 3) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 13 > x) || (mouseButton == 1 && ChattingConfig.INSTANCE.getRightClickCopy())) {
+ Transferable message = hook.getChattingChatComponent(Mouse.getY());
+ if (message == null) return;
+ try {
+ Toolkit.getDefaultToolkit().getSystemClipboard().setContents(message, null);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else if ((hook.getRight() + ModCompatHooks.getXOffset() + 13) <= x && (hook.getRight() + ModCompatHooks.getXOffset()) + 23 > x) {
+ ChatLine chatLine = hook.getHoveredLine(Mouse.getY());
+ if (chatLine == null) return;
+ ((GuiNewChatAccessor) Minecraft.getMinecraft().ingameGUI.getChatGUI()).getDrawnChatLines().removeIf(line -> ((ChatLineHook) line).getUniqueId() == ((ChatLineHook) chatLine).getUniqueId());
+ ((GuiNewChatAccessor) Minecraft.getMinecraft().ingameGUI.getChatGUI()).getChatLines().removeIf(line -> ((ChatLineHook) line).getUniqueId() == ((ChatLineHook) chatLine).getUniqueId());
}
}
+
}
@ModifyArg(method = "keyTyped", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiChat;sendChatMessage(Ljava/lang/String;)V"), index = 0)