JsonPatcher
JsonPatcher 是一个模组,允许你在不覆盖的前提下修改数据包和资源包中的 JSON 文件。
这主要对模组开发者和整合包制作者有用,但玩家也可用它来修改自己的包。
V2 免责声明
JsonPatcher v2 目前处于测试阶段。V2 引入了一系列新功能,包括针对模组和整合包的全局补丁。
v2 的文档位于 jsonpatcher-docs.mattidragon.dev。
不过,文档尚不完整且部分已过时。
在某些情况下,查阅旧版 Wiki 可能是更好的选择。
使用方法
Gradle 依赖(适用于模组开发者)
你可以像这样将 jsonpatcher 添加到你的模组构建脚本中:
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
modImplementation(include("com.github.mattidragon:jsonpatcher:${jsonpatcher_version}"))
}
要开始使用 jsonpatcher,只需在你的数据包的 data/<namespace>/jsonpatch 目录或资源包的 assets/<namespace>/jsonpatch 目录中创建一个扩展名为 .jsonpatch 的文件即可。
你需要以如下形式的 @version 元标签开始你的补丁。
这将让 jsonpatcher 知道你的补丁适用于此版本。
未来你可能可以通过更多方式来选择版本。
@version "1"
接下来,你需要选择要修补的文件。
这是通过 @target 元标签完成的。所有元标签都遵循 JSON 格式。
你可以使用字符串选择单个文件,使用对象进行更广泛的匹配,
或使用数组进行多次匹配。如果数组中的任何选择器匹配,补丁就会生效。
现在你可以开始修改目标文件了。补丁文件使用类 C 语法。
你可以使用 $ 访问目标文件的内容。它可以像变量一样使用,
或者你也可以直接在它后面放置你想访问的属性。
有关该语言的更多信息,请参阅 Wiki。
JsonPatcher
JsonPatcher is a mod that allows you to modify json files in datapacks and resourcepacks without overriding them.
This is primarily useful for mod developers and pack makers, but can also be used by players to modify their own packs.
V2 Disclaimer
JsonPatcher v2 is currently in beta. V2 introduces a bunch of new features including global patches for mods and modpacks.
Documentation for v2 is available at jsonpatcher-docs.mattidragon.dev.
The documentation is however quite incomplete and partially outdated.
For some cases it might be best to consult the old wiki instead.
Usage
Gradle dependency (for mod developers)
You can add jsonpatcher to your mods buildscript like this:
repositories {
maven {
url 'https://jitpack.io'
}
}
dependencies {
modImplementation(include("com.github.mattidragon:jsonpatcher:${jsonpatcher_version}"))
}
To begin using jsonpatcher, just create a file with the .jsonpatch extension
in the data/<namespace>/jsonpatch directory of your datapack
or assets/<namespace>/jsonpatch directory of your resourcepack.
You'll want to begin your patch with a @version meta tag like this.
This will let jsonpatcher know that your patch will work with this version.
In the future you may be able to select a version in more ways.
@version "1"
Next you'll want to select the files you want to patch.
This is done with the @target meta tag. All meta tags follow a json format.
You can either select a single file with a string, use an object for broader selections,
or use an array for multiple selections. If any selector in the array matches, the patch will apply.
Now you can begin modifying the target file. The patch files use a c-like syntax.
You can access the target files contents with $. It can be used like a variable,
or you can put the property you want to access directly after it.
For more info on the language, see the wiki.
评论 0
登录后参与评分
还没有评论,来抢沙发吧