aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-03-04 04:22:39 +0100
committer alemi <me@alemi.dev>2023-03-04 04:22:39 +0100
commitdd9b4bb539326c949f4452547239d3c1c02442cb (patch)
tree907bcfebf10bdd3ac11fe61fa9f944a3acbde2f7 /src
parent0dc1644c148a9483c545efd08ae2094e85d5a55f (diff)
feat: jank way to prevent chat clearing
Diffstat (limited to 'src')
-rw-r--r--src/main/java/ftbsc/bscv/patches/ChatPatch.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/patches/ChatPatch.java b/src/main/java/ftbsc/bscv/patches/ChatPatch.java
new file mode 100644
index 0000000..b8bc887
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/patches/ChatPatch.java
@@ -0,0 +1,32 @@
+package ftbsc.bscv.patches;
+
+import ftbsc.lll.processor.annotations.Injector;
+import ftbsc.lll.processor.annotations.Patch;
+import ftbsc.lll.processor.annotations.Target;
+import net.minecraft.client.gui.NewChatGui;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.*;
+
+
+public class ChatPatch {
+
+ @Patch(value = NewChatGui.class, reason = "add hook to prevent chat from being cleared")
+ public abstract static class ChatClearInterceptor implements Opcodes {
+
+ /*
+ * TODO this patch is pretty bad because it prevents everyone from clearing the chat history.
+ *
+ * A better (but more complex) approach would be to patch in Minecraft.setScreen() and prevent clearing
+ * chat history upon getting into main menu / multiplayer menu
+ */
+
+ @Target
+ abstract void clearMessages(boolean clearSent);
+
+ @Injector
+ public void inject(ClassNode clazz, MethodNode main) {
+ main.instructions.insert(new InsnNode(RETURN));
+ }
+ }
+
+}