|
|
本帖最后由 全自动电棍 于 2025-10-12 00:34 编辑
AI Twekas is perhaps the worst mod to learn Starsector modding from, because of the complexity and hacks required to access obfuscated symbols.
The important part is the division into two jars: lanucher and core. Launcher is the normal, modding-API compliant part, loaded by Starsector. It's responsible for analyzing the game binary, finding the correct obfuscated symbols for the given game version and injecting them into ai tweaks core.
The core, once injected with obf symbols, is launched with a custom class loader. The class loader, among other things, circumvents the game reflection ban.
You'll find all the features inside core jar. The jar is divided mostly into two parts: player assist and ship AI. If you want to modify the ship AI, just look at the CustomShipAI class and find your way from there.
——Genir
从上文可知,AITweak通过以Loader/Core形式使用自定义classloader加载敏感操作逻辑从而绕过了游戏类加载器的文件读写与反射限制。
基于上述启发,我们融入隔壁MC模组Cleanroom Relauncher中的思想大胆设想一下
——更进一步,直接中断游戏生命周期,并使用我们的类加载器(LaunchWrappr)重新启动游戏。
通过LaunchWrappr,我们可以使用IClassTransformer以及ITweak获取无限制操纵游戏类的能力。
而这一切只需要包装一下游戏主方法确保classpath正确,并保存重写后的类到文件系统完成持久化即可。
并且令人惊喜的是,fabric到如今依旧有方法可以通过LaunchWrapper启动,只是需要对GameProvider做一些调整。
这意味着你可以全都要,ASM和Mixin齐上阵😋
该做的cpw和lex已经替我们做过了,我们只需要享受成果就行了。
不过这真的很蠢,等于给launchwrapper前面又加了个launchwrapper,只是为了不用改启动参数,欢迎聪明人来指点一下😰
|
|