功能兼容矩阵

[!INFO] 实现类:makamys.coretweaks.Compat(探测)+ Config.shouldDisable(判定) 共 7 条冲突规则,探测 8 个外部 mod

探测方式:资源路径存在性检查

Compat 的 7 个方法里,6 个用 getResource(...) != null 在 classpath 上找 class 文件判断 mod 是否存在(不依赖 FML 的 mod 列表):

方法 检查的资源路径 探测目标
isBetterCrashesPresent /vfyjxf/bettercrashes/BetterCrashes.class BetterCrashes
isCrashGuardPresent /com/falsepattern/crashguard/CrashGuard.class CrashGuard
isBackport5160Present /ru/itaros/backport5160/Forge5160Plugin.class backport5160
isOptifinePresent /optifine/OptiFineTweaker.class OptiFine
isNotFinePresent /jss/notfine/NotFine.class NotFine
isLuminaPresent /com/falsepattern/lumina/api/LumiAPI.class LUMINA
isSupernovaPresent /com/mitchej123/supernova/core/SupernovaCore.class Supernova

⚠️ BetterCrashes 的包名 vfyjxf 是混淆后的产物, 这是 BetterCrashes 官方分布的实际包名,非笔误。

第 8 个探测:Hodgepodge(需读版本 + 配置)

isHodgepodgeChatLinkCrashFixEnabled 与上面 7 个不同 —— 它要读 mod 版本并解析其配置文件:

String version = getModVersion("com.mitchej123.hodgepodge.Hodgepodge");
if (version != null) {
    if (new ComparableVersion(version).compareTo(new ComparableVersion("1.6.14")) >= 0) {
        Configuration config = new Configuration(new File(Launch.minecraftHome, "config/hodgepodge.cfg"));
        config.load();
        ConfigCategory cat = config.getCategory("fixes");
        if (cat.containsKey("fixUrlDetection")) {
            return cat.get("fixUrlDetection").getBoolean();
        } else {
            return true;   // 未知格式 -> 保守认为开启
        }
    }
}
return false;

三段判定:

  1. 用 ASM ClassReader + VersionRetrievingModClassVisitor 从 .class 常量池里读出 mod 版本(getModVersion)。
  2. 版本 < 1.6.14 → 返回 false(旧版无此功能)。
  3. >= 1.6.14 → 读 config/hodgepodge.cfg 的 fixes.fixUrlDetection; 键不存在时返回 true(源码注释:Unknown format, let's be on the safe side and yield)—— 即无法判定时保守地认为对方已启用, 从而禁用 CoreTweaks 的同名修复。

7 条禁用规则

Config.shouldDisable(FeatureSetting) 在配置加载期执行, 按 feature == <具体静态字段> 引用比较(非按名):

# 被禁用的功能 条件 日志
1 crashHandler BetterCrashes 存在 INFO
2 crashHandler CrashGuard 存在 INFO
3 fixForgeChatLinkCrash Hodgepodge ≥1.6.14 且其修复开启 INFO
4 fixEntityTracking backport5160 存在 INFO
5 tweakCloudHeightCheck NotFine 存在 INFO
6 fixHeightmapRange LUMINA 存在 INFO
7 fixHeightmapRange Supernova 存在 INFO
8 lightFixStare Supernova 存在 INFO

(crashHandler 与 fixHeightmapRange 各有 2 条,共 8 条分支、 覆盖 6 个功能。)

判定用 else if 链,故同一功能只报第一条命中的日志 (如 crashHandler 在 BetterCrashes 与 CrashGuard 同时存在时 只报 BetterCrashes)。

OptiFine 不在此矩阵中

Compat.isOptifinePresent() 不参与 shouldDisable, 而是直接在 MixinConfigPlugin.getMixins() 中作为 增益性门控使用:OptiFine 存在时才注入 3 个 OF 专属 Mixin (见 Tweak Mixin 与 Optimization Mixin)。

即 OptiFine 缺失不导致任何功能被禁用,只导致 OF 优化不生效。

FoamFix 的反向 hack

对 FoamFix 的处理不走 shouldDisable,而是在 MixinConfigPlugin.disableFoamFixJarDiscovererTransformer() 中 反射移除对方的 patcher,失败则放弃注入。 详见 Optimization Mixin。

禁用不写回配置

shouldDisable 只调用 feature.disable()(内存标记)与打日志, 从不修改配置文件。因此:

  • 用户在 .cfg 里仍看到 enableXxx=true;
  • 每次启动都会重新检测并重新禁用;
  • 想真正强制启用需把值改为 force(isActive() 的 FORCE 分支 忽略 disabled)。
机制 生效范围
force 绕过所有冲突检测
enable<Category>=false 关闭整个分类(_categories 分类下)

相关条目