组件完整性检查

基本信息

属性 值
主类 io.github.legacymoddingmc.unimixins.gasstation.GasStationModule
文件 module-gasstation/src/main/java/…/gasstation/GasStationModule.java
配套 …/unimixins/mixinbooterlegacy/MixinBooterLegacyModule.java
Logger unimixins-gasstation
启用版本 Minecraft 1.7.10

checkComponentIntegrity() —— 会抛异常的硬检查

源码注释:Logic copied from FalsePatternLib for interoperability (为互操作性而从 FalsePatternLib 抄来的逻辑)。

用 classExists(String)(内部走 getResource("/" + 点号转斜杠 + ".class") != null) 逐个探测必需组件:

探测的类 缺失时记为
com.falsepattern.gasstation.core.GasStationCore GasStation
makamys.mixingasm.api.TransformerInclusions Mixingasm
ru.timeconqueror.spongemixins.core.SpongeMixinsCore SpongeMixins
io.github.tox1cozz.mixinbooterlegacy.MixinBooterLegacyPlugin MixinBooterLegacy
ASM Opcodes 判定(见下) MixinBooterLegacy

ASM Opcodes 判定(双重条件)

if (!classExists("org.spongepowered.asm.lib.Opcodes")
    || classExists("org.spongepowered.libraries.org.objectweb.asm.Opcodes"))
    missingComponents.add("MixinBooterLegacy");

即两套 ASM 包名同时出现,或都不出现都判为缺失:

  • org.spongepowered.asm.lib.Opcodes 缺(GasStation / UniMixins 用的包名)
  • 或 org.spongepowered.libraries.org.objectweb.asm.Opcodes 在 (MixinBooterLegacy / GTNHMixins 用的包名)

这正是 ASMRemapperTransformer 要适配的差异, 在启动期被当作硬性前置条件校验。

⚠️ 失败行为:抛 RuntimeException

LOGGER.error("The following missing components were detected: " + missingComponents);
LOGGER.error("Please obtain mods which provide them.");
throw new RuntimeException("Missing components detected");

⚠️ 这是本仓唯一会因「缺组件」而硬失败的检查, 与 SanityCheckHelper 的「只 warn 不 throw」形成对比。 SanityCheckHelper 的注释明确说它抛的异常会被吞掉、只能 warn; 而本方法在调用栈上层(checkComponentIntegrity)直接抛。

⚠️ checkComponentIntegrity() 只在 SanityCheckHelper.isEnabled() 为真时才被调用 (见 init())。即把 enableIntegrityChecks 设为 false 会连带跳过这个硬检查 —— 硬失败可以被配置绕过。

init() 与 MixinBooterLegacyModule.init()

类 前缀列表 后续动作
GasStationModule gasstation-、mixinbooterlegacy-、spongemixins-、mixingasm-(4 个) 调 checkComponentIntegrity()
MixinBooterLegacyModule mixinbooterlegacy-(1 个) 无

⚠️ 两者调用的方法名是 warnIfJarPrefixesExist(无返回值的警告版), 而 module-mixin 的 MixinCore 调的是 checkIfJarPrefixesExist(返回 List<String> 版)。 是两个不同方法,不是同一个方法的两种用法。

⚠️ GasStationModule 的 4 个前缀比 MixinCore 的 3 个多一个 mixingasm-。 说「全仓统一检查 3 个前缀」是错的。

⚠️ 两个 Module 类都没有 @Mod 注解(GasStationModule 是普通 public class), 它们只是被 *Core 调用的静态工具类。 本仓的 gasstation modid 来自 GasStation.java, mixinbooterlegacy 来自 MixinBooterLegacyPlugin.Container(嵌套类)。

相关条目