diff options
author | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2021-12-21 21:17:29 +0700 |
---|---|---|
committer | Wyvest <45589059+Wyvest@users.noreply.github.com> | 2021-12-21 21:17:29 +0700 |
commit | 7ffe65977bef2a34262cf8690ba335ae5d915ef0 (patch) | |
tree | b03d4b0ee12c999a223e16e2103e60dd7751cbe2 /src/main/java/com | |
parent | 870da2e7fcf370233c9e64d55dd0295cec6665f0 (diff) | |
download | Chatting-7ffe65977bef2a34262cf8690ba335ae5d915ef0.tar.gz Chatting-7ffe65977bef2a34262cf8690ba335ae5d915ef0.tar.bz2 Chatting-7ffe65977bef2a34262cf8690ba335ae5d915ef0.zip |
Chat tabs
Diffstat (limited to 'src/main/java/com')
3 files changed, 54 insertions, 16 deletions
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java index be04586..4f9b2eb 100644 --- a/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java +++ b/src/main/java/com/raeids/stratus/mixin/GuiChatMixin.java @@ -1,7 +1,9 @@ package com.raeids.stratus.mixin; import com.raeids.stratus.config.StratusConfig; -import com.raeids.stratus.hook.ChatHookKt; +import com.raeids.stratus.hook.ChatSearchingKt; +import com.raeids.stratus.hook.ChatTab; +import com.raeids.stratus.hook.ChatTabs; import net.minecraft.client.gui.GuiChat; import net.minecraft.client.gui.GuiScreen; import org.spongepowered.asm.mixin.Mixin; @@ -15,46 +17,49 @@ public abstract class GuiChatMixin extends GuiScreen { @Inject(method = "initGui", at = @At("TAIL")) private void init(CallbackInfo ci) { if (StratusConfig.INSTANCE.getChatSearch()) { - ChatHookKt.initGui(); + ChatSearchingKt.initGui(); + } + for (ChatTab chatTab : ChatTabs.INSTANCE.getTabs()) { + buttonList.add(chatTab.getButton()); } } @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(); + if (ChatSearchingKt.getInputField() != null) { + ChatSearchingKt.getInputField().drawTextBox(); } } @Inject(method = "onGuiClosed", at = @At("TAIL")) private void onGuiClosed(CallbackInfo ci) { - ChatHookKt.setInputField(null); - ChatHookKt.setPrevText(""); + ChatSearchingKt.setInputField(null); + ChatSearchingKt.setPrevText(""); } @Inject(method = "updateScreen", at = @At("HEAD")) private void updateScreen(CallbackInfo ci) { - ChatHookKt.updateScreen(); + ChatSearchingKt.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()) { + if (ChatSearchingKt.getInputField() != null) { + if (ChatSearchingKt.getInputField().isFocused()) { ci.cancel(); - if (keyCode == 1 && ChatHookKt.getInputField().isFocused()) { - ChatHookKt.getInputField().setFocused(false); + if (keyCode == 1 && ChatSearchingKt.getInputField().isFocused()) { + ChatSearchingKt.getInputField().setFocused(false); return; } - ChatHookKt.getInputField().textboxKeyTyped(typedChar, keyCode); + ChatSearchingKt.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); + if (ChatSearchingKt.getInputField() != null) { + ChatSearchingKt.getInputField().mouseClicked(mouseX, mouseY, mouseButton); } } } diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java index 48e2525..bbe1e9b 100644 --- a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java +++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java @@ -1,10 +1,12 @@ package com.raeids.stratus.mixin; import com.raeids.stratus.Stratus; -import com.raeids.stratus.hook.ChatHookKt; +import com.raeids.stratus.hook.ChatSearchingKt; +import com.raeids.stratus.hook.ChatTabs; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ChatLine; import net.minecraft.client.gui.GuiNewChat; +import net.minecraft.util.IChatComponent; import org.spongepowered.asm.lib.Opcodes; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -21,6 +23,11 @@ import java.util.List; public class GuiNewChatMixin { @Shadow @Final private Minecraft mc; + @Inject(method = "setChatLine", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;floor_float(F)I", shift = At.Shift.AFTER)) + private void setDoing(IChatComponent chatComponent, int chatLineId, int updateCounter, boolean displayOnly, CallbackInfo ci) { + ChatTabs.INSTANCE.setDoing(true); + } + @Inject(method = "drawChat", at = @At("HEAD")) private void checkScreenshotKeybind(int j2, CallbackInfo ci) { if (Stratus.INSTANCE.getKeybind().isPressed()) { @@ -44,6 +51,6 @@ public class GuiNewChatMixin { @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); + return ChatSearchingKt.filterMessages(drawnChatLines); } } diff --git a/src/main/java/com/raeids/stratus/mixin/GuiUtilRenderComponentsMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiUtilRenderComponentsMixin.java new file mode 100644 index 0000000..05378cd --- /dev/null +++ b/src/main/java/com/raeids/stratus/mixin/GuiUtilRenderComponentsMixin.java @@ -0,0 +1,26 @@ +package com.raeids.stratus.mixin; + +import com.raeids.stratus.hook.ChatTabs; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.GuiUtilRenderComponents; +import net.minecraft.util.IChatComponent; +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; + +import java.util.Collections; +import java.util.List; + +@Mixin(GuiUtilRenderComponents.class) +public class GuiUtilRenderComponentsMixin { + @Inject(method = "splitText", at = @At("HEAD"), cancellable = true) + private static void cancelText(IChatComponent k, int s1, FontRenderer chatcomponenttext, boolean l, boolean chatcomponenttext2, CallbackInfoReturnable<List<IChatComponent>> cir) { + if (ChatTabs.INSTANCE.isDoing()) { + ChatTabs.INSTANCE.setDoing(false); + if (!ChatTabs.INSTANCE.shouldRender(k.getUnformattedTextForChat())) { + cir.setReturnValue(Collections.emptyList()); + } + } + } +} |