aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 14:51:55 -0500
committerWyvest <45589059+Wyvest@users.noreply.github.com>2023-01-14 14:51:55 -0500
commite52b994b8a7c32badab7017dc0040d6bfb1cbedb (patch)
treeb7f1005a994524ee4f55b4eb0cf70e5038aef07a /src/main/java/cc
parente574e54a53b87ef4bbb33404b6fdb6b97c72dd81 (diff)
downloadChatting-e52b994b8a7c32badab7017dc0040d6bfb1cbedb.tar.gz
Chatting-e52b994b8a7c32badab7017dc0040d6bfb1cbedb.tar.bz2
Chatting-e52b994b8a7c32badab7017dc0040d6bfb1cbedb.zip
split GuiNewChatMixin into different mixins
Diffstat (limited to 'src/main/java/cc')
-rw-r--r--src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java4
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java2
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java101
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java21
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java31
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java62
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_RemoveScrollBar.java25
-rw-r--r--src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_TextRendering.java29
8 files changed, 171 insertions, 104 deletions
diff --git a/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java b/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java
index d2ca6c1..19da778 100644
--- a/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java
+++ b/src/main/java/cc/woverflow/chatting/hook/GuiNewChatHook.java
@@ -17,9 +17,5 @@ public interface GuiNewChatHook {
throw new AssertionError("getFullMessage not overridden on GuiNewChat");
}
- String getPrevText();
-
- void setPrevText(String prevText);
-
int getTextOpacity();
}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
index a633a3d..5eced71 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiChatMixin.java
@@ -78,7 +78,7 @@ public abstract class GuiChatMixin extends GuiScreen {
return;
}
searchButton.getInputField().textboxKeyTyped(typedChar, keyCode);
- ChatSearchingManager.setPrevText(searchButton.getInputField().getText());
+ ChatSearchingManager.INSTANCE.setLastSearch(searchButton.getInputField().getText());
}
}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
index 17106bc..6d4a60d 100644
--- a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin.java
@@ -4,8 +4,6 @@ import cc.polyfrost.oneconfig.config.core.OneColor;
import cc.polyfrost.oneconfig.libs.universal.UMouse;
import cc.polyfrost.oneconfig.utils.Notifications;
import cc.woverflow.chatting.Chatting;
-import cc.woverflow.chatting.chat.ChatSearchingManager;
-import cc.woverflow.chatting.chat.ChatTabs;
import cc.woverflow.chatting.config.ChattingConfig;
import cc.woverflow.chatting.gui.components.CleanButton;
import cc.woverflow.chatting.hook.GuiNewChatHook;
@@ -15,25 +13,20 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
-import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
import java.awt.image.BufferedImage;
import java.util.List;
-import java.util.Locale;
@Mixin(value = GuiNewChat.class, priority = Integer.MIN_VALUE)
public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@@ -51,10 +44,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Shadow
@Final
private List<ChatLine> drawnChatLines;
- @SuppressWarnings({"FieldCanBeLocal", "unused"})
- private float percentComplete;
- private String chatting$previousText = "";
-
@Shadow
public abstract boolean getChatOpen();
@@ -66,12 +55,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Shadow
private int scrollPos;
- @Shadow
- @Final
- private List<ChatLine> chatLines;
-
- @Shadow
- public abstract void deleteChatLine(int id);
@Shadow public abstract int getChatWidth();
@@ -80,20 +63,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
@Unique
private static final ResourceLocation DELETE = new ResourceLocation("chatting:delete.png");
- @Inject(method = "printChatMessageWithOptionalDeletion", at = @At("HEAD"), cancellable = true)
- private void handlePrintChatMessage(IChatComponent chatComponent, int chatLineId, CallbackInfo ci) {
- handleChatTabMessage(chatComponent, chatLineId, mc.ingameGUI.getUpdateCounter(), false, ci);
- if (!EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.getUnformattedText()).toLowerCase(Locale.ENGLISH).contains(chatting$previousText.toLowerCase(Locale.ENGLISH))) {
- percentComplete = 1.0F;
- }
- }
-
- @Inject(method = "setChatLine", at = @At("HEAD"), cancellable = true)
- private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
- ChatSearchingManager.getCache().invalidateAll();
- handleChatTabMessage(chatComponent, chatLineId, updateCounter, displayOnly, ci);
- }
-
/*?
@Unique
private final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
@@ -107,14 +76,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
*/
- @Unique
- private ChatLine chatting$drawingLine = null;
-
- @Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ChatLine;getChatComponent()Lnet/minecraft/util/IChatComponent;"), locals = LocalCapture.CAPTURE_FAILSOFT)
- private void captureChatLine(int updateCounter, CallbackInfo ci, int i, boolean bl, int j, int k, float f, float g, int l, int m, ChatLine chatLine, int n, double d, int o, int p, int q) {
- chatting$drawingLine = chatLine;
- }
-
@Inject(method = "drawChat", at = @At("HEAD"))
private void checkScreenshotKeybind(int j2, CallbackInfo ci) {
if (Chatting.INSTANCE.getKeybind().isPressed()) {
@@ -184,11 +145,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
((color.getBlue() & 0xFF));
}
- @Redirect(method = "drawChat", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/GuiNewChat;drawnChatLines:Ljava/util/List;", opcode = Opcodes.GETFIELD))
- private List<ChatLine> injected(GuiNewChat instance) {
- return ChatSearchingManager.filterMessages(chatting$previousText, drawnChatLines);
- }
-
@ModifyVariable(method = "drawChat", at = @At("STORE"), ordinal = 7)
private int modifyYeah(int value) {
return chatting$textOpacity = (int) (((float) (getChatOpen() ? 255 : value)) * (mc.gameSettings.chatOpacity * 0.9F + 0.1F));
@@ -206,25 +162,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
*/
- @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"))
- private int redirectDrawString(FontRenderer instance, String text, float x, float y, int color) {
- return ModCompatHooks.redirectDrawString(text, x, y, color, chatting$drawingLine, false);
- }
-
- @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 1))
- private void redirectScrollBar(int left, int top, int right, int bottom, int color) {
- if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
- drawRect(left, top, right, bottom, color);
- }
- }
-
- @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 2))
- private void redirectScrollBar2(int left, int top, int right, int bottom, int color) {
- if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
- drawRect(left, top, right, bottom, color);
- }
- }
-
@Inject(method = "drawChat", at = @At("RETURN"))
private void checkStuff(int j2, CallbackInfo ci) {
if (!chatting$chatCheck && chatting$isHovering) {
@@ -232,12 +169,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
}
}
- @Inject(method = "getChatHeight", at = @At("HEAD"), cancellable = true)
- private void customHeight_getChatHeight(CallbackInfoReturnable<Integer> cir) {
- if (ChattingConfig.INSTANCE.getCustomChatHeight())
- cir.setReturnValue(Chatting.INSTANCE.getChatHeight(this.getChatOpen()));
- }
-
@Override
public int getRight() {
return chatting$right;
@@ -248,24 +179,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
return chatting$isHovering;
}
- private void handleChatTabMessage(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
- if (ChattingConfig.INSTANCE.getChatTabs()) {
- if (!ChatTabs.INSTANCE.shouldRender(chatComponent)) {
- percentComplete = 1.0F;
- if (chatLineId != 0) {
- deleteChatLine(chatLineId);
- }
- if (!displayOnly) {
- chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));
- while (this.chatLines.size() > (100 + ModCompatHooks.getExtendedChatLength())) {
- this.chatLines.remove(this.chatLines.size() - 1);
- }
- }
- ci.cancel();
- }
- }
- }
-
private void drawCopyChatBox(int right, int top) {
chatting$chatCheck = true;
GlStateManager.enableRescaleNormal();
@@ -281,7 +194,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
GlStateManager.blendFunc(770, 771);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
chatting$right = right;
- Gui.drawModalRectWithCustomSizedTexture(right + 1, top, 0f, 0f, 9, 9, 9, 9);
+ drawModalRectWithCustomSizedTexture(right + 1, top, 0f, 0f, 9, 9, 9, 9);
drawRect(right + 1, top, right + 10, top + 9, (((right + ModCompatHooks.getXOffset() + 3) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 13 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor()));
GlStateManager.disableAlpha();
GlStateManager.disableRescaleNormal();
@@ -292,7 +205,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 771);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
- Gui.drawModalRectWithCustomSizedTexture(right + 11, top, 0f, 0f, 9, 9, 9, 9);
+ drawModalRectWithCustomSizedTexture(right + 11, top, 0f, 0f, 9, 9, 9, 9);
drawRect(right + 11, top, right + 20, top + 9, (((right + ModCompatHooks.getXOffset() + 13) <= (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale()) && (right + ModCompatHooks.getXOffset()) + 23 > (UMouse.getScaledX() / mc.ingameGUI.getChatGUI().getChatScale())) ? CleanButton.Companion.getHoveredColor() : CleanButton.Companion.getColor()));
GlStateManager.disableLighting();
GlStateManager.popMatrix();
@@ -345,16 +258,6 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
}
@Override
- public String getPrevText() {
- return chatting$previousText;
- }
-
- @Override
- public void setPrevText(String prevText) {
- chatting$previousText = prevText;
- }
-
- @Override
public int getTextOpacity() {
return chatting$textOpacity;
}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java
new file mode 100644
index 0000000..d0b4db1
--- /dev/null
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatHeight.java
@@ -0,0 +1,21 @@
+package cc.woverflow.chatting.mixin;
+
+import cc.woverflow.chatting.Chatting;
+import cc.woverflow.chatting.config.ChattingConfig;
+import net.minecraft.client.gui.GuiNewChat;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin(GuiNewChat.class)
+public abstract class GuiNewChatMixin_ChatHeight {
+ @Shadow public abstract boolean getChatOpen();
+
+ @Inject(method = "getChatHeight", at = @At("HEAD"), cancellable = true)
+ private void customHeight_getChatHeight(CallbackInfoReturnable<Integer> cir) {
+ if (ChattingConfig.INSTANCE.getCustomChatHeight())
+ cir.setReturnValue(Chatting.INSTANCE.getChatHeight(getChatOpen()));
+ }
+}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java
new file mode 100644
index 0000000..b40ba52
--- /dev/null
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatSearching.java
@@ -0,0 +1,31 @@
+package cc.woverflow.chatting.mixin;
+
+import cc.woverflow.chatting.chat.ChatSearchingManager;
+import net.minecraft.client.gui.ChatLine;
+import net.minecraft.client.gui.GuiNewChat;
+import net.minecraft.util.IChatComponent;
+import org.objectweb.asm.Opcodes;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.List;
+
+@Mixin(GuiNewChat.class)
+public class GuiNewChatMixin_ChatSearching {
+ @Shadow @Final private List<ChatLine> drawnChatLines;
+
+ @Inject(method = "setChatLine", at = @At("HEAD"))
+ private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
+ ChatSearchingManager.getCache().invalidateAll();
+ }
+
+ @Redirect(method = "drawChat", at = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/GuiNewChat;drawnChatLines:Ljava/util/List;", opcode = Opcodes.GETFIELD))
+ private List<ChatLine> injected(GuiNewChat instance) {
+ return ChatSearchingManager.filterMessages(ChatSearchingManager.INSTANCE.getLastSearch(), drawnChatLines);
+ }
+}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java
new file mode 100644
index 0000000..1d29941
--- /dev/null
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_ChatTabs.java
@@ -0,0 +1,62 @@
+package cc.woverflow.chatting.mixin;
+
+import cc.woverflow.chatting.chat.ChatSearchingManager;
+import cc.woverflow.chatting.chat.ChatTabs;
+import cc.woverflow.chatting.config.ChattingConfig;
+import cc.woverflow.chatting.utils.ModCompatHooks;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ChatLine;
+import net.minecraft.client.gui.GuiNewChat;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.IChatComponent;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import java.util.List;
+import java.util.Locale;
+
+@Mixin(GuiNewChat.class)
+public abstract class GuiNewChatMixin_ChatTabs {
+ @Shadow @Final private Minecraft mc;
+
+ @Shadow public abstract void deleteChatLine(int id);
+
+ @Shadow @Final private List<ChatLine> chatLines;
+ @SuppressWarnings({"FieldCanBeLocal", "unused"})
+ private float percentComplete; //betterchat support
+
+ @Inject(method = "printChatMessageWithOptionalDeletion", at = @At("HEAD"), cancellable = true)
+ private void handlePrintChatMessage(IChatComponent chatComponent, int chatLineId, CallbackInfo ci) {
+ handleChatTabMessage(chatComponent, chatLineId, mc.ingameGUI.getUpdateCounter(), false, ci);
+ if (!EnumChatFormatting.getTextWithoutFormattingCodes(chatComponent.getUnformattedText()).toLowerCase(Locale.ENGLISH).contains(ChatSearchingManager.INSTANCE.getLastSearch().toLowerCase(Locale.ENGLISH))) {
+ percentComplete = 1.0F;
+ }
+ }
+
+ @Inject(method = "setChatLine", at = @At("HEAD"), cancellable = true)
+ private void handleSetChatLine(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
+ handleChatTabMessage(chatComponent, chatLineId, updateCounter, displayOnly, ci);
+ }
+
+ private void handleChatTabMessage(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) {
+ if (ChattingConfig.INSTANCE.getChatTabs()) {
+ if (!ChatTabs.INSTANCE.shouldRender(chatComponent)) {
+ percentComplete = 1.0F;
+ if (chatLineId != 0) {
+ deleteChatLine(chatLineId);
+ }
+ if (!displayOnly) {
+ chatLines.add(0, new ChatLine(updateCounter, chatComponent, chatLineId));
+ while (this.chatLines.size() > (100 + ModCompatHooks.getExtendedChatLength())) {
+ this.chatLines.remove(this.chatLines.size() - 1);
+ }
+ }
+ ci.cancel();
+ }
+ }
+ }
+}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_RemoveScrollBar.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_RemoveScrollBar.java
new file mode 100644
index 0000000..347ea57
--- /dev/null
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_RemoveScrollBar.java
@@ -0,0 +1,25 @@
+package cc.woverflow.chatting.mixin;
+
+import cc.woverflow.chatting.config.ChattingConfig;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.gui.GuiNewChat;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+@Mixin(GuiNewChat.class)
+public class GuiNewChatMixin_RemoveScrollBar extends Gui {
+ @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 1))
+ private void redirectScrollBar(int left, int top, int right, int bottom, int color) {
+ if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
+ drawRect(left, top, right, bottom, color);
+ }
+ }
+
+ @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V", ordinal = 2))
+ private void redirectScrollBar2(int left, int top, int right, int bottom, int color) {
+ if (!ChattingConfig.INSTANCE.getRemoveScrollBar()) {
+ drawRect(left, top, right, bottom, color);
+ }
+ }
+}
diff --git a/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_TextRendering.java b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_TextRendering.java
new file mode 100644
index 0000000..84c184e
--- /dev/null
+++ b/src/main/java/cc/woverflow/chatting/mixin/GuiNewChatMixin_TextRendering.java
@@ -0,0 +1,29 @@
+package cc.woverflow.chatting.mixin;
+
+import cc.woverflow.chatting.utils.ModCompatHooks;
+import net.minecraft.client.gui.ChatLine;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.GuiNewChat;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Unique;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
+
+@Mixin(value = GuiNewChat.class, priority = Integer.MIN_VALUE)
+public class GuiNewChatMixin_TextRendering {
+ @Unique
+ private ChatLine chatting$drawingLine = null;
+
+ @Inject(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/ChatLine;getChatComponent()Lnet/minecraft/util/IChatComponent;"), locals = LocalCapture.CAPTURE_FAILSOFT)
+ private void captureChatLine(int updateCounter, CallbackInfo ci, int i, boolean bl, int j, int k, float f, float g, int l, int m, ChatLine chatLine, int n, double d, int o, int p, int q) {
+ chatting$drawingLine = chatLine;
+ }
+
+ @Redirect(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I"))
+ private int redirectDrawString(FontRenderer instance, String text, float x, float y, int color) {
+ return ModCompatHooks.redirectDrawString(text, x, y, color, chatting$drawingLine, false);
+ }
+}