模组支持状态(ModSupportState)
基本信息
| 属性 | 值 |
|---|---|
| 枚举类 | net.blay09.mods.craftingtweaks.CraftingTweaks.ModSupportState(是 @Mod 类的内部枚举) |
| 取值数量 | 4 |
| 配置位置 | config/craftingtweaks.cfg → addons 分类,键名 = 模组 modid |
| 默认值 | enabled |
| 容错 | ModSupportState.fromName 捕获 IllegalArgumentException 后回落到 ENABLED |
| 存储 | CraftingTweaks.configMap,Map<String, ModSupportState> |
4 个取值穷举
| 枚举值 | 配置字符串 | 按钮 | 热键 | 精确门控点 |
|---|---|---|---|---|
ENABLED |
enabled |
✅ 显示 | ✅ 生效 | — |
BUTTONS_ONLY |
buttons_only |
✅ 显示 | ❌ 屏蔽 | ClientProxy.initGui 放行;onClientTick 的 rotate/clear/balance 分支不放行 |
HOTKEYS_ONLY |
hotkeys_only |
❌ 不显示 | ✅ 生效 | ClientProxy.initGui 不放行;onClientTick 放行 |
DISABLED |
disabled |
❌ 不显示 | ❌ 屏蔽 | 两处都不放行 |
两处门控的源码写法完全对称:
- 按钮:
if (config == ENABLED || config == BUTTONS_ONLY) provider.initGui(...) - 热键:
if (config == ENABLED || config == HOTKEYS_ONLY) { rotate / clear / balance }
⚠️ 两个热键不受本状态门控
判定块结构导致以下 3 个键在 provider 之外或判定之外:
| 热键 | 是否受 ModSupportState 约束 |
原因 |
|---|---|---|
| 旋转 / 均分 / 清空 | ✅ 受约束 | 在 if (config == ENABLED || config == HOTKEYS_ONLY) 内 |
| 绑定按键 | ❌ 不受约束 | 嵌套在 if (provider != null) 内、if (config == ...) 外 |
| 压缩物品 / 拆分物品 | ❌ 不受约束 | 判定块整体在 if (provider != null) 之外 |
所以把某个模组设为 buttons_only 并不会关掉它的压缩/拆分热键。
默认种子表(preInit 硬编码 19 项)
以下 modid 在 preInit 里被显式 configMap.put(...),值为源码给定:
| modid | 预置状态 |
|---|---|
minecraft |
ENABLED |
TConstruct |
ENABLED |
appliedenergistics2 |
BUTTONS_ONLY |
DraconicEvolution |
ENABLED |
Natura |
ENABLED |
Thaumcraft |
ENABLED |
MineFactoryReloaded |
ENABLED |
Forestry |
ENABLED |
Railcraft |
ENABLED |
BuildCraft|Factory |
ENABLED |
RotaryCraft |
ENABLED |
TwilightForest |
ENABLED |
terrafirmacraft |
ENABLED |
ganyssurface |
ENABLED |
jacb |
ENABLED |
bluepower |
ENABLED |
BiblioCraft |
ENABLED |
ThermalExpansion |
ENABLED |
Backpack |
ENABLED |
⚠️ appliedenergistics2 被设了两次:preInit 种入 BUTTONS_ONLY,
postInit 开头(所有 Compatibility.*() 调用之前)又显式
configMap.put("appliedenergistics2", ModSupportState.BUTTONS_ONLY) 重申一次。
第二次是硬覆盖,不受玩家配置影响 —— 也就是说在配置文件里把 AE2 改成
enabled 或 hotkeys_only 无效,最终总是 BUTTONS_ONLY。
未预置的模组
getModSupportState(modId) 在 configMap 里找不到时回落到 ENABLED 并写回
缓存(suportState = ENABLED; configMap.put(modId, ENABLED))。
典型的未预置项是 Avaritia —— 它在 Compatibility.avaritia() 中被注册,
但不在上述 19 项种子表里,因此默认恒为 enabled。
配置项动态生成机制
addons 分类的键是懒生成的,不是预置清单:
preInit读addonConfig.getString("minecraft", "addons", "enabled", ...)- 随后遍历
addonConfig.getCategory("addons").values()把文件中已存在的每一个键 灌进configMap registerProvider(String, TweakProvider)每注册一个 provider,就为它的 modid 调一次addonConfig.getString(modid, "addons", "enabled", ...), 缺失时把enabled补写进文件postInit末尾addonConfig.save()落盘
因此删掉某个键不会禁用支持,下次启动会被重新补成 enabled;
只有显式写成 disabled / buttons_only / hotkeys_only 才生效。