Configuration Handler

基本信息

net.glease.tc4tweak.ConfigurationHandler —— 枚举单例(INSTANCE), 负责加载、保存、迁移配置。

初始化

config = new Configuration(f, ConfigurationVersion.latest().getVersionMarker());
ConfigurationVersion.migrateToLatest(config);
loadConfig(false);

三步:指定版本创建 → 迁移到最新 → 加载。 构造器还把自己注册到 FMLCommonHandler 总线以接收 ConfigChangedEvent.OnConfigChangedEvent(第 98 行 → loadConfig(true))。

loadConfig(boolean send) 的 send 语义

loadConfig 末尾会调 TC4Tweak.INSTANCE.detectAndSendConfigChanges() 向客户端广播配置。send 参数控制是否执行该广播 —— 即「本地改配置」与「读配置」用同一个方法,靠 flag 区分。

配置分组

顶层只有 client 一个 category,其余以点号复合形式出现在 getCategory("client.browser_scale")、getCategory("general.infusion_recipes")、 getCategory("general.saved_link")、getCategory("general.infusion_recipes.nbtcarryover") 等嵌套分组中。

分组路径 键
general checkWorkbenchRecipes、arcaneCraftingHistorySize、smallerJars、moreRandomizedLoot、dispenserShootPrimalArrow、decantMaxBlocks、earthShockHarmMode、alternativeAddStack
client inverted、updateInterval、addTooltip、mappingThreadNiceType、limitBookSearchToCategory、limitOversizedNodeRender、categoryOrder、addClearButton、addResearchSearch、infusionMatrixMaxDrift、completionCounterStyle
client.browser_scale scale、infer、maximum、minimum、considerSearchArea
general.infusion_recipes oreDictMode
general.infusion_recipes.nbtcarryover enable、armorToolOnly、carryOverWhitelist
general.saved_link enable、saveCompleteLink、debug

非默认取值的字段默认值(源码字段初值,非配置文件内容)

字段 初值
browserHeight 230
browserWidth 256
infusionMatrixLimitDrift 12f
infusionOreDictMode InfusionOreDictMode.Default
counterStyle CompletionCounterStyle.Current
earthShockHarmMode EarthShockHarmMode.OnlyLiving
categoryOrder new ArrayList<>()(随后填入 BASICS/THAUMATURGY/ALCHEMY/ARTIFICE/GOLEMANCY/ELDRITCH)

布尔字段(inverted、addTooltip 等)声明时未给初值, Java 默认 false;实际生效值以 loadConfig 读到的配置为准 —— 属于「未调用 setter 即默认值」的典型,不能凭字段声明断言。

自定义类型

类型 用途
InfusionOreDictMode 灌注词典模式,见 Infusion 模块
CompletionCounterStyle 研究完成计数样式(静态 get(name))
EarthShockHarmMode 大地冲击伤害模式(静态 get(name))
StringOrderingEntry categoryOrder 的数组元素类型
TObjectDoubleMap<UUID> championMods 冠军 mod 权重

相关条目

源码

  • src/main/java/net/glease/tc4tweak/ConfigurationHandler.java
  • src/main/java/net/glease/tc4tweak/ConfigurationVersion.java
  • src/main/java/net/glease/tc4tweak/config/StringOrderingEntry.java