aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-22 13:21:40 +0700
committerWyvest <45589059+Wyvest@users.noreply.github.com>2021-12-22 13:21:40 +0700
commit9a4918e4f18d07e7ddbe6278371d6d36ac25d8cf (patch)
tree60650f056ca1cbb8f4d488bf35ce5619bdbd8594
parent136710660fbcf27e33a53723024203b2a7b25dae (diff)
downloadChatting-9a4918e4f18d07e7ddbe6278371d6d36ac25d8cf.tar.gz
Chatting-9a4918e4f18d07e7ddbe6278371d6d36ac25d8cf.tar.bz2
Chatting-9a4918e4f18d07e7ddbe6278371d6d36ac25d8cf.zip
fix chat screenshot feature with patcher and halfway with betterchat
-rw-r--r--build.gradle2
-rw-r--r--src/dummy/java/club/sk1er/patcher/config/PatcherConfig.java6
-rw-r--r--src/dummy/java/com/llamalad7/betterchat/BetterChat.java7
-rw-r--r--src/dummy/java/com/llamalad7/betterchat/ChatSettings.java6
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java2
-rw-r--r--src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java18
-rw-r--r--src/main/kotlin/com/raeids/stratus/Stratus.kt12
-rw-r--r--src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt18
8 files changed, 55 insertions, 16 deletions
diff --git a/build.gradle b/build.gradle
index 8aa11ec..dfcb3ab 100644
--- a/build.gradle
+++ b/build.gradle
@@ -121,7 +121,9 @@ reobf {
tasks.reobfJar.dependsOn tasks.shadowJar
sourceSets {
+ dummy
main {
+ compileClasspath += dummy.output
ext.refMap = "mixins.${mod_id}.refmap.json"
}
}
diff --git a/src/dummy/java/club/sk1er/patcher/config/PatcherConfig.java b/src/dummy/java/club/sk1er/patcher/config/PatcherConfig.java
new file mode 100644
index 0000000..b652649
--- /dev/null
+++ b/src/dummy/java/club/sk1er/patcher/config/PatcherConfig.java
@@ -0,0 +1,6 @@
+package club.sk1er.patcher.config;
+
+public class PatcherConfig {
+ public static boolean transparentChatInputField;
+ public static boolean chatPosition;
+}
diff --git a/src/dummy/java/com/llamalad7/betterchat/BetterChat.java b/src/dummy/java/com/llamalad7/betterchat/BetterChat.java
new file mode 100644
index 0000000..14a5a70
--- /dev/null
+++ b/src/dummy/java/com/llamalad7/betterchat/BetterChat.java
@@ -0,0 +1,7 @@
+package com.llamalad7.betterchat;
+
+public class BetterChat {
+ public static ChatSettings getSettings() {
+ throw new AssertionError("Wyvest");
+ }
+}
diff --git a/src/dummy/java/com/llamalad7/betterchat/ChatSettings.java b/src/dummy/java/com/llamalad7/betterchat/ChatSettings.java
new file mode 100644
index 0000000..3059eb7
--- /dev/null
+++ b/src/dummy/java/com/llamalad7/betterchat/ChatSettings.java
@@ -0,0 +1,6 @@
+package com.llamalad7.betterchat;
+
+public class ChatSettings {
+ public int xOffset;
+ public int yOffset;
+}
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java
index 1e09a8f..4445f99 100644
--- a/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java
+++ b/src/main/java/com/raeids/stratus/mixin/GuiIngameForgeMixin.java
@@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
-@Mixin(value = GuiIngameForge.class, remap = false)
+@Mixin(value = GuiIngameForge.class, remap = false, priority = Integer.MIN_VALUE)
public class GuiIngameForgeMixin implements GuiIngameForgeHook {
private int stratus$x = 0;
private int stratus$y = 0;
diff --git a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
index 2f4a13a..86db154 100644
--- a/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
+++ b/src/main/java/com/raeids/stratus/mixin/GuiNewChatMixin.java
@@ -1,19 +1,19 @@
package com.raeids.stratus.mixin;
+import club.sk1er.patcher.config.PatcherConfig;
+import com.llamalad7.betterchat.BetterChat;
import com.raeids.stratus.Stratus;
import com.raeids.stratus.config.StratusConfig;
import com.raeids.stratus.hook.ChatSearchingKt;
import com.raeids.stratus.hook.ChatTabs;
-import com.raeids.stratus.hook.GuiIngameForgeHook;
import com.raeids.stratus.hook.GuiNewChatHook;
-import gg.essential.universal.UResolution;
+import gg.essential.universal.UMouse;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.IChatComponent;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
-import org.lwjgl.input.Mouse;
import org.spongepowered.asm.lib.Opcodes;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -69,6 +69,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
: linesToDraw;
}
+ //TODO: fix with betterchat
@ModifyArgs(method = "drawChat", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/GuiNewChat;drawRect(IIIII)V"), slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/util/MathHelper;clamp_double(DDD)D"), to = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;enableBlend()V")))
private void captureDrawRect(Args args) {
int left = args.get(0);
@@ -76,10 +77,11 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
int right = args.get(2);
int bottom = args.get(3);
if (mc.currentScreen instanceof GuiChat) {
- final int k1 = Mouse.getX() * UResolution.getScaledWidth() / this.mc.displayWidth;
- final int l1 = UResolution.getScaledHeight() - Mouse.getY() * UResolution.getScaledHeight() / this.mc.displayHeight - 1;
- int mouseX = k1 - ((GuiIngameForgeHook) mc.ingameGUI).getX() - 2;
- int mouseY = l1 - ((GuiIngameForgeHook) mc.ingameGUI).getY() - 20;
+ float f = this.getChatScale();
+ int mouseX = MathHelper.floor_double(UMouse.getScaledX()) - (3 + (Stratus.INSTANCE.isBetterChat() ? BetterChat.getSettings().xOffset : 0));
+ int mouseY = MathHelper.floor_double(UMouse.getScaledY()) - (27 + (Stratus.INSTANCE.isBetterChat() ? BetterChat.getSettings().yOffset : 0) + (Stratus.INSTANCE.isPatcher() && PatcherConfig.chatPosition ? 12 : 0));
+ mouseX = MathHelper.floor_float((float)mouseX / f);
+ mouseY = -(MathHelper.floor_float((float)mouseY / f)); //WHY DO I NEED TO DO THIS
if (mouseX >= left && mouseY < bottom && mouseX < right + 9 && mouseY >= top) {
stratus$shouldCopy = true;
drawCopyChatBox(right, top);
@@ -137,7 +139,7 @@ public abstract class GuiNewChatMixin extends Gui implements GuiNewChatHook {
ScaledResolution scaledresolution = new ScaledResolution(this.mc);
int i = scaledresolution.getScaleFactor();
float f = this.getChatScale();
- int k = mouseY / i - 27;
+ int k = mouseY / i - (27 + (Stratus.INSTANCE.isBetterChat() ? BetterChat.getSettings().yOffset : 0) + (Stratus.INSTANCE.isPatcher() && PatcherConfig.chatPosition ? 12 : 0));
k = MathHelper.floor_float((float) k / f);
if (k >= 0) {
diff --git a/src/main/kotlin/com/raeids/stratus/Stratus.kt b/src/main/kotlin/com/raeids/stratus/Stratus.kt
index 0bf6831..6559cc5 100644
--- a/src/main/kotlin/com/raeids/stratus/Stratus.kt
+++ b/src/main/kotlin/com/raeids/stratus/Stratus.kt
@@ -15,8 +15,10 @@ import net.minecraft.client.settings.KeyBinding
import net.minecraft.client.shader.Framebuffer
import net.minecraftforge.common.MinecraftForge.EVENT_BUS
import net.minecraftforge.fml.client.registry.ClientRegistry
+import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.Mod
import net.minecraftforge.fml.common.event.FMLInitializationEvent
+import net.minecraftforge.fml.common.event.FMLPostInitializationEvent
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent
@@ -41,6 +43,10 @@ object Stratus {
var doTheThing = false
lateinit var jarFile: File
private set
+ var isPatcher = false
+ private set
+ var isBetterChat = false
+ private set
private val fileFormatter: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd_HH.mm.ss'.png'")
@@ -62,6 +68,12 @@ object Stratus {
Updater.update()
}
+ @Mod.EventHandler
+ fun onPostInitialization(event: FMLPostInitializationEvent) {
+ isPatcher = Loader.isModLoaded("patcher")
+ isBetterChat = Loader.isModLoaded("betterchat")
+ }
+
@SubscribeEvent
fun onTickEvent(event: TickEvent.ClientTickEvent) {
if (event.phase == TickEvent.Phase.START && Minecraft.getMinecraft().theWorld != null && Minecraft.getMinecraft().thePlayer != null && (Minecraft.getMinecraft().currentScreen == null || Minecraft.getMinecraft().currentScreen is GuiChat)) {
diff --git a/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt b/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt
index 3c15842..38e44ad 100644
--- a/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt
+++ b/src/main/kotlin/com/raeids/stratus/hook/CleanButton.kt
@@ -1,5 +1,7 @@
package com.raeids.stratus.hook
+import club.sk1er.patcher.config.PatcherConfig
+import com.raeids.stratus.Stratus
import gg.essential.universal.UResolution
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiButton
@@ -31,13 +33,15 @@ class CleanButton(buttonId: Int, x: Int, y: Int, widthIn: Int, heightIn: Int, pr
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f)
hovered =
mouseX >= xPosition && mouseY >= yPosition && mouseX < xPosition + width && mouseY < yPosition + height
- drawRect(
- xPosition,
- yPosition,
- xPosition + width,
- yPosition + height,
- if (hovered) hoveredColor else color
- )
+ if (!Stratus.isPatcher || !PatcherConfig.transparentChatInputField) {
+ drawRect(
+ xPosition,
+ yPosition,
+ xPosition + width,
+ yPosition + height,
+ if (hovered) hoveredColor else color
+ )
+ }
mouseDragged(mc, mouseX, mouseY)
var j = 14737632
if (packedFGColour != 0) {