Config
基本信息
| 属性 | 值 |
|---|---|
| 配置文件 | 由 event.suggestedConfigurationFile 决定(ThaumcraftResearchTweaks.kt:41) |
| 源码类 | ResearchTweaksConfig(config/ResearchTweaksConfig.kt) |
| 配置项总数 | 2(均在 client 分类下) |
| 加载时机 | preInit(@Mod.EventHandler fun preInit) |
@Mod.EventHandler
fun preInit(event: FMLPreInitializationEvent) {
ResearchTweaksConfig.loadConfig(Configuration(event.suggestedConfigurationFile))
}
2 项配置
| 配置键 | 分类 | 类型 | 默认 | 说明 |
|---|---|---|---|---|
allowCombiningSameAspect |
client |
boolean | false |
“Should an aspect be allowed to be dragged onto itself? (e.g. Ignis onto Ignis)” |
researchTableSortingOrder |
client |
int | 0 |
三种元素排序方式,取值 0–2 |
(ResearchTweaksConfig.kt:14-24)
researchTableSortingOrder 取值
对应 Kotlin 枚举 AspectSortingOptions(ResearchTweaksConfig.kt:4-8):
| 值 | 枚举名 | 含义(源码原文) |
|---|---|---|
| 0(默认) | SIMPLE_TO_COMPLEX |
“Aspects that take more combining are listed towards the bottom” |
| 1 | ALPHABETICAL_FILL_LEFT |
“Sorted alphabetically, tries to fill the entire left side before right” |
| 2 | ALPHABETICAL_BALANCED |
“Sorted alphabetically, left will have the first half of all aspects, right will have the second half” |
数值边界是「枚举大小」而非硬编码
config.getInt("researchTableSortingOrder", "client", 0,
AspectSortingOptions.values().size - 1, // ← 3 - 1 = 2
...)
上界取自 values().size - 1(ordinal 风格),当前恰好等于 2。若日后向枚举中间插入新值,边界会失效——因为 size - 1 假设 ordinal 与下标连续。
字段默认值与枚举默认值一致
class ClientConfig {
var allowCombiningSameAspect: Boolean = false
var researchTableSortingOrder: Int = AspectSortingOptions.SIMPLE_TO_COMPLEX.ordinal // == 0
}
字段初值与 config.get 的第三参数一致,故配置缺失时不会出现「字段默认 0 而 get 默认非 0」的不一致——这与本仓库其它模组常见的陷阱不同,此处是正确的。
唯一读取方
researchTableSortingOrder 被 ResearchTableGuiFactory.palletComponents() 读取,决定左右两个元素面板的内容来源(ResearchTableGuiFactory.kt:83-100):
| 排序方式 | 左面板 | 右面板 |
|---|---|---|
SIMPLE_TO_COMPLEX |
tree::allOrderLeaning |
tree::allEntropyLeaning |
ALPHABETICAL_FILL_LEFT |
allAspects.take(48) |
allAspects.drop(48) |
ALPHABETICAL_BALANCED |
allAspects.take(size / 2) |
allAspects.drop(size / 2) |
allAspects = Aspect.aspects.values.sortedBy { it.tag }(PortContainer.kt:40)——按 tag 名排序。
maxAspectsPerSide = 48 是硬编码字面量(ResearchTableGuiFactory.kt:84),不是配置项。
分支末尾有
else -> throw Exception("unknown config ...")(:99)——因上界被钳制在 0–2,实际不可达。
相关条目
- Aspect Combination - 排序的实际效果
- Research Table GUI - 面板布局
- TableBlockMixin