AngelicaTweaker(coremod 入口)
基本信息
| 属性 | 值 |
|---|---|
| 类 | com.gtnewhorizons.angelica.loading.AngelicaTweaker |
| 路径 | src/main/java/com/gtnewhorizons/angelica/loading/AngelicaTweaker.java |
| 声明 | @IFMLLoadingPlugin.MCVersion("1.7.10")(:22) |
| 实现接口 | IFMLLoadingPlugin, IEarlyMixinLoader(:23) |
| 登记位置 | gradle.properties:122 coreModClass = loading.AngelicaTweaker |
源码里的关键警告注释
:15-21 有一段大写标题的注释,是理解整个 coremod 设计的必要前提:
// ================== Important ==================
// Due to a bug caused by this class both implementing
// IFMLLoadingPlugin and IEarlyMixinLoader,
// the IClassTransformer registered in this class
// will not respect the sorting index defined.
// They will instead use default index 0 which means they will see
// obfuscated mappings and not SRG mappings when running outside of dev env.
// ===============================================
含义:AngelicaTweaker 同时实现 IFMLLoadingPlugin 与 IEarlyMixinLoader 会触发一个已知缺陷,导致它注册的 IClassTransformer 不遵守排序索引,一律用默认 index 0;在非开发环境下这些 transformer 会看到混淆映射而非 SRG 映射。
这正是 RFB 路径与 LaunchWrapper 路径必须分开的原因之一。
构造:客户端/服务端分叉
// :25-38
public AngelicaTweaker() {
if (FMLLaunchHandler.side().isClient()) {
final AngelicaClientTweaker clientTweaker = new AngelicaClientTweaker();
loadingPlugin = clientTweaker;
mixinLoader = clientTweaker;
} else {
loadingPlugin = null;
mixinLoader = null;
LogManager.getLogger("Angelica").info("Trying to get more FPS on your server ? :kekw:");
}
}
服务端走 else 分支:两个字段都置 null,只打一条带 :kekw: 梗的日志。Angelica 在服务端不做任何注入。
全部转发方法
AngelicaTweaker 自身不含逻辑,每个 IFMLLoadingPlugin 方法都判空后转发给 loadingPlugin:
| 方法 | 行 | 委托目标 |
|---|---|---|
getASMTransformerClass() |
:41-47 |
AngelicaClientTweaker |
getModContainerClass() |
:49-55 |
同上 |
getSetupClass() |
:57-… |
同上 |
其余 IEarlyMixinLoader 方法 |
— | mixinLoader(同一个 AngelicaClientTweaker 实例) |
即:真正的逻辑全在 AngelicaClientTweaker,本类只是「客户端则代理,服务端则空转」的外壳。
两条加载路径
Angelica 同时支持两套类加载引导,由是否安装 RFB 决定:
| 路径 | 判定依据 | transformer 来源 |
|---|---|---|
| RetroFuturaBootstrap (RFB) | Launch.blackboard["angelica.rfbPluginLoaded"] == TRUE |
AngelicaRfbPlugin |
| 经典 LaunchWrapper | 同上为 FALSE |
AngelicaClientTweaker.getASMTransformerClass() |
RFB 路径由 src/main/resources/META-INF/rfb-plugin 声明,AngelicaRfbPlugin.onConstruction 会把 angelica.rfbPluginLoaded 写入黑板。
相关条目
- AngelicaClientTweaker - 真正实现全部逻辑的类
- AngelicaRfbPlugin - RFB 路径的 3 个 transformer
- CompatHandlers - transformer 列表的第一来源
- NotFine AsmTransformers - transformer 列表的第二来源
- AngelicaMod - mod 容器本身