
Hocon 资源加载器
将加载以`.hocon`结尾的包文件作为hocon格式
本模组用于为资源包或数据包使用 HOCON。
HOCON 的语法更加灵活,并支持变量和 include 等高级语法,可以减少样板代码。
模组会使用 HOCON 解析器加载包中任何以 .hocon 结尾的文件,并欺骗游戏将其视为 json 文件。
因此,它不应与任何已经使用 json 格式的包冲突。
需要在 pack.mcmeta 中启用,如下所示:
{
"pack": {
"pack_format": 15,
"description": {
"translate": "settingsun.pack",
"fallback": "Assets of SettingSun"
},
"supported_formats": [15, 22]
},
"hoconresourceloader" : {
"enabled": true
}
}
HOCON 的优势
includeurl、file(可用于资源/数据包配置)、通过标识符引用 Minecraft 资源- 使用
include,你可以包含原始 json 文件并修改其中的值,而不必编辑整个文件。比 JsonPatch 方便得多 - 更多内容请参见 https://github.com/lightbend/config/blob/main/HOCON.md
示例
资源包位于 https://github.com/SettingDust/HoconResourceLoader/tree/main/mod/run/resourcepacks/test-resources 的结果
- https://github.com/SettingDust/HoconResourceLoader/blob/main/mod/run/resourcepacks/test-resources/assets/minecraft/models/item/stone.hocon
# 读取文件时相对的当前目录是 Minecraft 运行目录。 # 通常是 `.minecraft` 或 `.minecraft/versions/{NAME}` 目录 # 这里是 `{PROJECT_DIR}/mod/run` include file("dirt.hocon")
- https://github.com/SettingDust/HoconResourceLoader/blob/main/mod/run/resourcepacks/test-resources/assets/minecraft/models/item/dirt.hocon
parent: "minecraft:block/stone"
- https://github.com/SettingDust/HoconResourceLoader/blob/main/mod/run/resourcepacks/test-resources/assets/minecraft/models/item/oak_log.hocon
# 支持标识符 include "minecraft:models/item/dirt.json"
- https://github.com/SettingDust/HoconResourceLoader/blob/main/mod/run/resourcepacks/test-resources/assets/minecraft/models/item/oak_wood.hocon
# 会尝试在传递给资源管理器的起始路径下查找。 # 这里是 `models/` include "minecraft:item/dirt.json"
- https://github.com/SettingDust/HoconResourceLoader/blob/main/mod/run/resourcepacks/test-resources/assets/minecraft/models/item/torch.hocon
# 具体来说,被 include 的 json 文件不会被解析为 hocon。 # 因此,你可以对 json 文件进行补丁,并将 hocon 文件作为 json 提供给游戏。 include "minecraft:models/item/torch.json" textures.layer0 = "minecraft:block/soul_torch"
致谢
正在加载版本记录…
正在加载评论…
评论在新手盒子客户端中发表,这里同步展示。