源码缺陷清单
以下均为读源码实测得到的问题,附文件与行号。
1. 版本号是构建期占位符,仓库内无真实值
tonius/neiintegration/NEIIntegration.java:23
public static final String VERSION = "GRADLETOKEN_VERSION";
@Mod(version = NEIIntegration.VERSION) 直接引用它。gradle.properties:80 声明 gradleTokenVersion = GRADLETOKEN_VERSION,构建时由 GTNH 约定插件替换为真实版本号。
源码仓库内不存在任何真实版本号字面量——本分类不编造具体版本数字。mcmod.info 中是 "${modVersion}" 占位符,同样只在构建期展开。
2. RecipeHandlerDumper 目录位置不一致
mods/mcforge/ 根目录下有 RecipeHandlerDumper.java,而另外 10 个 dumper 全部在 mods/mcforge/dumpers/ 下。
后果:MCForgeDumpers.loadConfig() 能找到它们(全限定名不同不影响),但按目录批量处理/排除某个子目录时会漏掉它。属一致性问题,非功能缺陷。
3. 完全未使用的编译期依赖
dependencies.gradle 中有两条 compileOnly 依赖在 src/main 全目录零引用:
compileOnly('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-911-GTNH:dev')
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.57:dev')
grep -rni "buildcraft\|appeng\|ae2\|applied" src/main --include=*.java 0 命中,Integrations.getIntegrations() 也不含对应集成。属历史残留。
对照:
cofh-core虽同为compileOnly,但确有引用——RecipeHandlerSludgeBoiler.java:16与RecipeHandlerLaserDrill.java:17importcofh.lib.util.WeightedRandomItemStack。由于未被 shade,运行时必须自行安装 CoFH Core,否则这两个 MFR handler 加载失败。
4. 目标 mod 只判存在不判版本
Utils 提供两个重载:
public static boolean isModLoaded(String modid) { return Loader.isModLoaded(modid); }
public static boolean isModLoaded(String modid, String versionRangeString) { ... }
带版本范围的实现用 VersionParser.parseRange + DefaultArtifactVersion.containsVersion 严格比较,但 6 个集成无一使用——全部只传 modid。
后果:目标 mod 的大版本变更不会触发跳过,handler 仍会注册,可能在运行时抛异常。作者提供的配置描述也承认了这点:“Disable if this part of the mod causes crashes.”
另有 3 条依赖来自 CurseMaven 且用 deobfCurse(...),无版本范围约束,升级时同样易静默失配。
5. ProcessConfig 在 preInit 中改写 integrations 列表
integrations = Integrations.getIntegrations(); // 先赋 6 个
Config.preInit(evt); // 内部 processConfig() itr.remove()
processConfig() 对 NEIIntegration.integrations 做 itr.remove()。若 preInit 因任何原因被调用两次(例如某些 coremod 重复触发 preInit),第二次会拿到已被裁剪过的列表,导致已关闭的集成无法恢复、且 isValid() 不会被重新求值。当前 FML 生命周期下不会发生,但该列表可变且无幂等保护。
6. setRequiresMcRestart(true) 只加在集成开关上
6 个集成开关标记了 setRequiresMcRestart(true),而 Handlers 段与 Tooltips 段的 20 个开关没有。这与实际一致(tooltip 与 handler 配方可即时重载),但两种标记混用易被误读为「全部需重启」。
7. mcmod.info 的 url / updateUrl 为空
src/main/resources/mcmod.info:
"url": "",
"updateUrl": "",
authorList 为 ["tonius11"],credits 为 "ChickenBones, mistaqur, iTitus, and anyone else who helped making the mod, directly or indirectly"。README 首行注明 “Forked and maintained by the GTNH Modpack”——当前维护方是 GTNH Modpack,但 mcmod.info 里的 author 仍是原作者 tonius11,且无仓库 URL。
8. mcmod.info 描述措辞夸大
"description": "NEI handlers for all of the mods, one at a time."
「all of the mods」与实际不符——本 mod 只覆盖 6 个目标 mod(Forge/HarvestCraft/Railcraft/MFR/BigReactors/Electrical Age),且其中 4 个是 compileOnly。README 的定位反而更准确(playground + 兜底容器)。
9. 未使用的 @SuppressWarnings("rawtypes")
ConfigGui.getConfigElements 标注 @SuppressWarnings("rawtypes"),但方法内实际用的是 List<IConfigElement>(已参数化)。该注解是历史遗留,无实际抑制对象。
10. isEnabledByDefault() 是单点钩子
IntegrationBase.isEnabledByDefault() 默认 return true,6 个集成无一覆写。即 Integrations 段的 6 个开关默认值全部是 true,与 Handlers/Tooltips 段的 false 形成对比。方法存在但无差异化实现。