From 797f1f3d33c491930fcd35f39a985231d8f01ec6 Mon Sep 17 00:00:00 2001 From: Shirona1337 Date: Thu, 21 May 2026 21:23:39 +0800 Subject: [PATCH] refactor: drop Encryption, fix init order, simplify shutdown - Remove unused Encryption class (AES wrapper around shit.zen.utils) and its construction from ZenClient bootstrap; drop dead TimerPatch import. - Defer ConfigManager.loadAll() and CommandManager.initCommands() so configs load only after modules are registered, fixing values that were silently discarded. - Make isOwner() return true so the local user is treated as owner. - Rename ZenClient.disconnectFromServer() to shutdown() and pin the MinecraftPatch close hook to At.Type.HEAD so it runs before the game tears down its subsystems. - README: invite users to file issues / open PRs for missing features. Co-Authored-By: Claude Opus 4.7 --- README.md | 2 +- src/main/java/shit/zen/ZenClient.java | 14 +++---- .../java/shit/zen/patch/MinecraftPatch.java | 6 +-- .../java/shit/zen/utils/misc/Encryption.java | 41 ------------------- 4 files changed, 8 insertions(+), 55 deletions(-) delete mode 100644 src/main/java/shit/zen/utils/misc/Encryption.java diff --git a/README.md b/README.md index fd909a2..9f2760d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Open Zen [WIP] -> 截止至目前,Open Zen仍然处于早期构建阶段。大量特性可能仍不可用,请谅解! +> 截止至目前,Open Zen仍然处于早期构建阶段。大量特性可能仍不可用,请谅解!当您发现有不可用的功能,欢迎开Issues描述或直接提交Pull Request,我们将不胜感激! **Open Zen** 是 *Zen* Minecraft 客户端的反混淆源码版本,几乎是由 [Claude](https://claude.com/)协助逆向得到。目标版本为 **Minecraft 1.20.1 + Forge 47.4.20**。 diff --git a/src/main/java/shit/zen/ZenClient.java b/src/main/java/shit/zen/ZenClient.java index d171211..9fa19ab 100644 --- a/src/main/java/shit/zen/ZenClient.java +++ b/src/main/java/shit/zen/ZenClient.java @@ -38,8 +38,6 @@ import shit.zen.patch.MinecraftPatch; import shit.zen.patch.PacketUtilsPatch; import shit.zen.patch.PlayerPatch; import shit.zen.patch.PlayerTabOverlayPatch; -import shit.zen.patch.TimerPatch; -import shit.zen.utils.misc.Encryption; import shit.zen.utils.rotation.RotationHandler; @Mod(value = "hey") @@ -64,7 +62,6 @@ public class ZenClient extends ClientBase { private HudManager hudManager; private LagManager lagManager; private TargetManager targetManager; - private Encryption encryption; private int reconnectAttempts; public ZenClient() { @@ -88,15 +85,13 @@ public class ZenClient extends ClientBase { this.moduleManager = new ModuleManager(); this.hudManager = new HudManager(); this.commandManager = new CommandManager(); - this.commandManager.initCommands(); this.configManager = new ConfigManager(); - this.configManager.loadAll(); this.lagManager = new LagManager(); - this.eventBus.register(this.lagManager); this.targetManager = new TargetManager(); + this.eventBus.register(this.lagManager); this.eventBus.register(this.targetManager); this.eventBus.register(this); - this.encryption = new Encryption(Encryption.Algorithm.AES); + this.commandManager.initCommands(); registerPatches(); if (PatchAgent.getInstrumentation() != null) { PatchAgent.installPatchesAndRetransform(); @@ -117,6 +112,7 @@ public class ZenClient extends ClientBase { if (isReady() && !moduleInit) { moduleInit = true; this.moduleManager.initModules(); + this.configManager.loadAll(); } } @@ -131,10 +127,10 @@ public class ZenClient extends ClientBase { } public static boolean isOwner(String username) { - return false; + return true; } - public void disconnectFromServer() { + public void shutdown() { isReady = false; if (this.configManager != null) { this.configManager.saveAll(); diff --git a/src/main/java/shit/zen/patch/MinecraftPatch.java b/src/main/java/shit/zen/patch/MinecraftPatch.java index f9a37d6..ed3b944 100644 --- a/src/main/java/shit/zen/patch/MinecraftPatch.java +++ b/src/main/java/shit/zen/patch/MinecraftPatch.java @@ -70,11 +70,9 @@ public class MinecraftPatch { } } - @Inject(method = "close", desc = "()V") + @Inject(method = "close", desc = "()V", at = @At(At.Type.HEAD)) public static void onClose(Minecraft minecraft, CallbackInfo callbackInfo) { - if (ZenClient.isReady()) { - ZenClient.getInstance().disconnectFromServer(); - } + ZenClient.getInstance().shutdown(); } @Inject(method = "setLevel", desc = "(Lnet/minecraft/client/multiplayer/ClientLevel;)V") diff --git a/src/main/java/shit/zen/utils/misc/Encryption.java b/src/main/java/shit/zen/utils/misc/Encryption.java deleted file mode 100644 index 578c036..0000000 --- a/src/main/java/shit/zen/utils/misc/Encryption.java +++ /dev/null @@ -1,41 +0,0 @@ -package shit.zen.utils.misc; - -import shit.zen.utils.ByteCipher; - -public class Encryption { - public enum Algorithm { - AES(new byte[16]), - DES(new byte[8]); - - public final byte[] iv; - - Algorithm(byte[] iv) { - this.iv = iv; - } - } - - private final ByteCipher cipher; - public final Algorithm algo; - public int keyLength = 0; - - public Encryption(Algorithm algorithm) { - this.algo = algorithm; - this.cipher = new ByteCipher(algorithm.iv); - } - - public String encryptString(String s) throws Exception { - return s; - } - - public byte[] encryptBytes(byte[] b) throws Exception { - return b; - } - - public String decryptString(String s) throws Exception { - return s; - } - - public byte[] decryptBytes(byte[] b) throws Exception { - return b; - } -}