FoamFix Mod
基本信息
pl.asie.foamfix.FoamFixMod —— @Mod 入口。
@Mod(name = "FoamFix", modid = "foamfix", version = "@VERSION@", acceptableRemoteVersions="*")
| 注解字段 |
值 |
modid |
foamfix(全小写;与 build.properties 的 mod_id=FoamFix 大小写不一致) |
name |
FoamFix |
version |
"@VERSION@" —— 构建期占位符,源码读不到真实版本 |
acceptableRemoteVersions |
"*" —— 允许任意端版本加入 |
| 成员 |
行 |
说明 |
@Mod.Instance FoamFixMod instance |
— |
— |
@SidedProxy(modId = "foamfix") ProxyCommon proxy |
— |
ProxyClient / ProxyCommon |
4 个生命周期钩子
| 钩子 |
行 |
动作 |
preinit(FMLPreInitializationEvent) |
— |
取得 logger → 条件注册事件处理器 → 客户端 Ears 补丁 → removePackageManifestMap |
init(FMLInitializationEvent) |
— |
条件执行 LaunchWrapperRuntimeFix.weakenResourceCache() |
serverStarting(FMLServerStartingEvent) |
— |
条件注册 /ghostbuster 命令 |
serverStopped(FMLServerStoppedEvent) |
— |
无条件调用 GhostBusterLogger.saveLogFile() |
| 开关 |
动作 |
ArrowDingTweakEnabled |
注册 ArrowDingTweakEventHandler(FML bus + Forge bus) |
ToolDesyncFixEnabled + Side.CLIENT |
注册 ToolDesyncFixEventHandler —— 且必须 handler.isValid(),否则 logger.error("Could not initialize ToolDesyncFixEventHandler!") |
applyEarsPatch() 返回 true + Side.CLIENT |
反射调用重打包的 Ears.onPreInit |
lwRemovePackageManifestMap |
LaunchWrapperRuntimeFix.removePackageManifestMap() |
⚠️ 调试残留
System.out.println(System.getProperty("sun.boot.class.path"));
System.out.println(Arrays.toString(((URLClassLoader) ClassLoader.getSystemClassLoader()).getURLs()));
两行 System.out.println 留在 preinit 里,每次启动向 stdout 打印类路径 ——
是遗留调试代码(对 sun.boot.class.path 的强转在部分启动器下会抛
ClassCastException,且未被捕获)。
版本读取
@VERSION@ 由 Gradle 在构建期替换。要确认真实版本应读
build.properties 的 mod_version=1.0.3,不是源码字符串。
相关条目
源码
src/main/java/pl/asie/foamfix/FoamFixMod.java
build.properties