feat: jank way to prevent chat clearing

This commit is contained in:
əlemi 2023-03-04 04:22:39 +01:00
parent 0dc1644c14
commit dd9b4bb539
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -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));
}
}
}