From dd9b4bb539326c949f4452547239d3c1c02442cb Mon Sep 17 00:00:00 2001 From: alemi Date: Sat, 4 Mar 2023 04:22:39 +0100 Subject: [PATCH] feat: jank way to prevent chat clearing --- .../java/ftbsc/bscv/patches/ChatPatch.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/main/java/ftbsc/bscv/patches/ChatPatch.java 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)); + } + } + +}