aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java60
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiNewChatAccessor.java15
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java49
3 files changed, 124 insertions, 0 deletions
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java
new file mode 100644
index 0000000..be04586
--- /dev/null
+++ b/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java
@@ -0,0 +1,60 @@
+package com.raeids.stratus.mixin;
+
+import com.raeids.stratus.config.StratusConfig;
+import com.raeids.stratus.hook.ChatHookKt;
+import net.minecraft.client.gui.GuiChat;
+import net.minecraft.client.gui.GuiScreen;
+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(GuiChat.class)
+public abstract class GuiChatMixin extends GuiScreen {
+
+ @Inject(method = "initGui", at = @At("TAIL"))
+ private void init(CallbackInfo ci) {
+ if (StratusConfig.INSTANCE.getChatSearch()) {
+ ChatHookKt.initGui();
+ }
+ }
+
+ @Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiTextField;drawTextBox()V", shift = At.Shift.AFTER))
+ private void yeah(int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
+ if (ChatHookKt.getInputField() != null) {
+ ChatHookKt.getInputField().drawTextBox();
+ }
+ }
+
+ @Inject(method = "onGuiClosed", at = @At("TAIL"))
+ private void onGuiClosed(CallbackInfo ci) {
+ ChatHookKt.setInputField(null);
+ ChatHookKt.setPrevText("");
+ }
+
+ @Inject(method = "updateScreen", at = @At("HEAD"))
+ private void updateScreen(CallbackInfo ci) {
+ ChatHookKt.updateScreen();
+ }
+
+ @Inject(method = "keyTyped", at = @At("HEAD"), cancellable = true)
+ private void keyTyped(char typedChar, int keyCode, CallbackInfo ci) {
+ if (ChatHookKt.getInputField() != null) {
+ if (ChatHookKt.getInputField().isFocused()) {
+ ci.cancel();
+ if (keyCode == 1 && ChatHookKt.getInputField().isFocused()) {
+ ChatHookKt.getInputField().setFocused(false);
+ return;
+ }
+ ChatHookKt.getInputField().textboxKeyTyped(typedChar, keyCode);
+ }
+ }
+ }
+
+ @Inject(method = "mouseClicked", at = @At("HEAD"))
+ private void mouseClicked(int mouseX, int mouseY, int mouseButton, CallbackInfo ci) {
+ if (ChatHookKt.getInputField() != null) {
+ ChatHookKt.getInputField().mouseClicked(mouseX, mouseY, mouseButton);
+ }
+ }
+}
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatAccessor.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatAccessor.java
new file mode 100644
index 0000000..cc697d0
--- /dev/null
+++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatAccessor.java
@@ -0,0 +1,15 @@
+package com.raeids.stratus.mixin;
+
+import net.minecraft.client.gui.ChatLine;
+import net.minecraft.client.gui.GuiChat;
+import net.minecraft.client.gui.GuiNewChat;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+import java.util.List;
+
+@Mixin (GuiNewChat.class)
+public interface GuiNewChatAccessor {
+ @Accessor
+ List<ChatLine> getDrawnChatLines();
+}
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
new file mode 100644
index 0000000..48e2525
--- /dev/null
+++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
@@ -0,0 +1,49 @@
+package com.raeids.stratus.mixin;
+
+import com.raeids.stratus.Stratus;
+import com.raeids.stratus.hook.ChatHookKt;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ChatLine;
+import net.minecraft.client.gui.GuiNewChat;
+import org.spongepowered.asm.lib.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.ModifyVariable;
+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 {
+ @Shadow @Final private Minecraft mc;
+
+ @Inject(method = "drawChat", at = @At("HEAD"))
+ private void checkScreenshotKeybind(int j2, CallbackInfo ci) {
+ if (Stratus.INSTANCE.getKeybind().isPressed()) {
+ Stratus.INSTANCE.setDoTheThing(true);
+ }
+ }
+
+ @ModifyVariable(method = "drawChat", at = @At("HEAD"), argsOnly = true)
+ private int setUpdateCounterWhjenYes(int updateCounter) {
+ return Stratus.INSTANCE.getDoTheThing() ? 0 : updateCounter;
+ }
+
+ @ModifyVariable(method = "drawChat", at = @At("STORE"), index = 2)
+ private int setChatLimitWhenYes(int linesToDraw) {
+ return Stratus.INSTANCE.getDoTheThing()
+ ? GuiNewChat.calculateChatboxHeight(mc.gameSettings.chatHeightFocused) / 9
+ : linesToDraw;
+ }
+
+ @Shadow @Final private List<ChatLine> drawnChatLines;
+
+ @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 ChatHookKt.filterMessages(drawnChatLines);
+ }
+}