主题 (Themes)
基本信息
| 属性 | 值 |
|---|---|
| 主题定义文件 | src/main/resources/assets/betterquesting/bq_themes.json |
| 主题条目数 | 8 |
| 加载器 | betterquesting.client.themes.ThemeRegistry(单例 INSTANCE) |
| 运行时主题 | betterquesting.client.themes.ResourceTheme |
| 兼容旧格式 | betterquesting.client.themes.ThemeLegacy + LegacyThemeLoader |
| 当前主题配置项 | BQ_Settings.curTheme,默认 "betterquesting:light" |
| 纹理 / 颜色 / 线条工厂 | 5 / 3 / 2(ResourceRegistry.java:33-44) |
8 个主题
全部条目以 betterquesting: 为域,无一使用旧版 themeType 字段(grep -c '"themeType"' bq_themes.json = 0),故 8 条全部走新版解析路径,无一条落入 ThemeLegacy 分支。
| # | 主题 ID | 名称 | 父主题 |
|---|---|---|---|
| 1 | betterquesting:light |
Standard Light | none |
| 2 | betterquesting:dark |
Standard Dark | none |
| 3 | betterquesting:overworld |
Overworld | betterquesting:dark |
| 4 | betterquesting:nether |
Nether | betterquesting:dark |
| 5 | betterquesting:stronghold |
Stronghold | betterquesting:dark |
| 6 | betterquesting:ender |
Ender | betterquesting:dark |
| 7 | betterquesting:vanilla |
Vanilla | betterquesting:light |
| 8 | betterquesting:new_test |
Semi-Transparent | none |
主题 3–6 是「维度皮肤」:共用 dark 作为基底,仅覆盖背景与强调色,对应主世界 / 下界 / stronghold / 末地四种色调。主题 7 回到 light 基底,是最接近原版观感的一套。
⚠️ 主题 8
betterquesting:new_test(Semi-Transparent)带new_test命名,是明显的开发期产物。但它在bq_themes.json中是一条完整且有效的条目,加载循环不按名字过滤任何主题(ThemeRegistry.java:245-283无 id 白/黑名单),故它确实会被加载并出现在主题选择列表中。本条目据实记录,不做剔除。
主题加载流程
ThemeRegistry 从资源域读 JSON 数组,逐条处理(ThemeRegistry.java:245-283):
- 非
JsonObject的条目跳过并 WARNInvalid theme entry at index …(:248-252) - 含
themeType的条目走旧格式分支,WARNDeprecated legacy theme entry …后loadLegacy(:256-261)—— 本仓 0 条命中 - 读
themeParent(缺省null)、themeName(缺省Unnamed Theme)、themeID(缺省取themeName)(:263-266) themeID经toLowerCase().trim().replaceAll(" ", "_")规范化;不含:则自动补当前资源域(:267-270)- 重名自动改名:
while (themes.containsKey(themeId)) themeId = new ResourceLocation(domain, idRaw + n++);(:274)—— 同名条目不会互相覆盖,而是被追加数字后缀 new ResourceTheme(parentID, themeId, themeName)构造失败则 ERROR 并跳过(:278-283)- 逐个纹理条目按
textureType查ResourceRegistry.getTexReg().getFactory(typeID);工厂缺失则 ERRORUnknown texture type …并跳过该纹理(:285-301)
源码另有两处防御:已解析过的相同 JSON 会被跳过(:240-242,基于摘要比较);NULL_TEXTURE / NULL_LINE / NULL_COLOR 三个兜底对象在纹理或工厂缺失时代替(:65-70)。
资源工厂注册表
ResourceRegistry 在构造期注册 10 个工厂,分三张表(ResourceRegistry.java:31-45):
| 表 | 工厂数 | 成员 |
|---|---|---|
TEX_REG |
5 | FactorySimpleTexture / FactorySlicedTexture / FactoryLayeredTexture / FactorySlideShowTexture / FactoryColorTexture |
COL_REG |
3 | FactoryColorStatic / FactoryColorSequence / FactoryColorPulse |
LIN_REG |
2 | FactorySimpleLine / FactoryDirectionalLine |
ResourceRegistry 末尾留有一条 // TODO: Sounds?(ResourceRegistry.java:62)—— 音效尚不支持主题化。
交叉验证:实际使用 vs 已注册
已注册工厂与主题 JSON 实际引用的工厂逐一对账:
| 表 | 已注册 | JSON 中出现 | 未被使用 |
|---|---|---|---|
TEX_REG |
5 | texture_sliced ×190、texture_simple ×4(共 194) |
texture_layered、texture_slideshow、texture_color |
COL_REG |
3 | color_static ×57、color_pulse ×10(共 67) |
color_sequence |
LIN_REG |
2 | line_directional ×12、line_simple ×9(共 21) |
无 —— 2 个全部在用 |
10 个工厂中 6 个被当前主题使用。未被使用的 4 个(3 个纹理 + 1 个颜色)不是死代码 —— 它们是 IFactoryData 公开扩展面的一部分,供整合包主题 JSON 引用;ResourceRegistry 构造期无条件注册全部 10 个。
统计口径:JSON 中 textureType 键共 194 处、colorType 67 处、lineType 21 处,合计 282 个资源条目。按主题分解为 7 × 24 + 26 = 194 个纹理(new_test 比其余 7 个多 2 个),与总数吻合。
数值
| 数值名 | 值 |
|---|---|
| 主题条目数 | 8 |
走旧格式(themeType)的条目 |
0 |
顶层(themeParent = none)主题 |
3(light / dark / new_test) |
| 每主题纹理数 | 24(new_test 为 26) |
| 派生主题 | 5(overworld / nether / stronghold / ender 继承 dark;vanilla 继承 light) |
| json 中资源条目总数 | 282(纹理 194 / 颜色 67 / 线条 21) |
| 已注册 / 被使用的工厂(纹理 / 颜色 / 线条) | 10 总计;被使用 6(纹理 2 / 颜色 2 / 线条 2) |
| 未被任何主题使用的工厂 | 4(texture_layered、texture_slideshow、texture_color、color_sequence) |
| 主题化的音效 | 0(ResourceRegistry.java:62 留 // TODO: Sounds?) |