SupernovaCore

基本信息

com.mitchej123.supernova.core.SupernovaCore —— coremod 加载入口:IFMLLoadingPlugin + IEarlyMixinLoader。

@IFMLLoadingPlugin.MCVersion("1.7.10")
public class SupernovaCore implements IFMLLoadingPlugin, IEarlyMixinLoader

接口实现

方法 行 返回
getMixinConfig() 48 mixins.supernova.early.json
getMixins(Set<String>) 53 IMixins.getEarlyMixins(Mixins.class, loadedCoreMods)
getASMTransformerClass() 58 null —— 不用 ASM transformer
getModContainerClass() 63 com.mitchej123.supernova.compat.ecl.EasyColoredLightsDummyContainer
getSetupClass() 68 null
injectData(Map) 73 空实现
getAccessTransformerClass() 76 null

getModContainerClass() 指向 EasyColoredLights 兼容容器 —— 见 EasyColoredLights Dummy Container。

static 初始化块:配置 + 模式仲裁

静态块在类加载时(即游戏启动最早阶段)执行三件事:

1. 注册配置

ConfigurationManager.registerConfig(SupernovaConfig.class);

失败则 throw new RuntimeException("Failed to register Supernova config", e) —— 启动即崩。

2. 用资源探测判断 ChunkAPI

CHUNKAPI_PRESENT = getClassLoader().getResource(
    "com/falsepattern/chunk/api/DataRegistry.class") != null;

⚠️ 不检测 modid,而检测资源路径是否存在。 因此只要 classpath 上有 ChunkAPI 的 jar(含被其它 mod 间接依赖的情况) 就会判定为「存在」。这是比 Loader.isModLoaded("chunkapi") 更宽松的判据。

3. 缺 ChunkAPI 时强制降级为 SCALAR

if (!CHUNKAPI_PRESENT && !SupernovaConfig.isScalarMode()) {
    LOG.warn("ChunkAPI not found -- forcing SCALAR mode (RGB requires ChunkAPI for persistence)");
    SupernovaConfig.lightingMode = LightingMode.SCALAR;
    ConfigurationManager.save(SupernovaConfig.class);
}

这是本 mod 最重要的行为: SCALAR 会改写用户配置并立即保存—— 用户设的 RGB 在缺 ChunkAPI 时被永久改成 SCALAR, 装了 ChunkAPI 后不会自动改回。

Angelica 彩色光照启用

} else if (getResource("com/gtnewhorizons/angelica/api/BlockLightProvider.class") != null) {
    AngelicaCompat.enableColoredLight();
    LOG.info("Enabled Angelica colored light support");
}

同样用资源路径探测 Angelica(而非 modid), 命中才启用彩色光照支持,见 Angelica Compat。

顺序很关键:先判 SCALAR(直接 return 跳过), 再判 Angelica。所以 SCALAR 模式下不会启用 Angelica 彩色光照。

相关条目

源码

  • src/main/java/com/mitchej123/supernova/core/SupernovaCore.java