JsonWrangler
一个满足你所有 JSON 修改需求的工具
Quilt 版本需要:QSL 和 GroovyDuvet
Forge 版本需要:GML
JsonWrangler 是一个 Minecraft 模组,允许通过可以打包进资源包或数据包的 Groovy 脚本来修改存储在 JSON 文件中的游戏数据和资源。
用法
JsonWrangler 应允许对基本上任何 JSON 文件进行修改,采用“赢家通吃”的行为——例如战利品表、模型、世界生成数据或动画元数据文件。如果你认为 JsonWrangler 应该处理某个文件但失败了,请提交错误报告。如果你希望修改指定路径的文件,例如 assets/minecraft/textures/block/magma.png.mcmeta 或 data/minecraft/loot_tables/chests/simple_dungeon.json,你应该在相同路径下创建一个以 .groovy 结尾的 Groovy 脚本——在这种情况下,即 assets/minecraft/textures/block/magma.png.mcmeta.groovy 或 data/minecraft/loot_tables/chests/simple_dungeon.json.groovy。在你的 Groovy 脚本中,你可以获得几个参数,并且必须返回一个将替换原始 JSON 文件的值。可返回的有效值包括地图(Map),其中地图键必须是字符串,值可以是列表、地图、数字、布尔值、字符串或日期。除了正常的 Groovy 特性外,你在脚本中还拥有以下可用变量:
json - 解析为地图的原始 JSON 文件
platform - "quilt" 或 "forge",取决于你运行的平台
override - 一个方法,如果调用它,会导致任何尝试修改同一文件的后续脚本不再运行
不同数据包或资源包中的多个脚本可以针对同一个文件——它们按照优先级从高到低(从“顶部”包到“底部”包)的顺序执行。如果脚本调用了 override(),则不会有更多脚本运行。
服务器
注意: 由于 JsonWrangler 加载的 Groovy 脚本可以执行任意代码,因此 JsonWrangler 不会加载来自服务器资源包的脚本。如果你希望从服务器资源包加载脚本,你必须首先将其复制为本地资源包。
示例
更改物品纹理
将以下文件放置在 assets/minecraft/models/item/apple.json.groovy 处,会将苹果的纹理更改为使用马铃薯纹理:
json?.textures?.layer0 = 'minecraft:item/potato'
return json
JsonWrangler
A tool for all your JSON-modifying needs
Quilt version requires: QSL and GroovyDuvet
Forge version requires: GML
JsonWrangler is a Minecraft mod which allows for the modification of game data and resources, as stored in JSON files,
through groovy scripts which can be packaged in resource or data packs.
Usage
JsonWrangler should allow modification of basically any JSON file with a "winner takes all" behavior - for instance,
loot tables, models, worldgen data, or animation metadata files. If JsonWrangler fails to wrangle a file that you think
it should, please submit a bug report. If you wish to modify a file at a given path, say,
assets/minecraft/textures/block/magma.png.mcmeta or data/minecraft/loot_tables/chests/simple_dungeon.json, you
should create a groovy script at same path, but with a .groovy at the end - in this case,
assets/minecraft/textures/block/magma.png.mcmeta.groovy or data/minecraft/loot_tables/chests/simple_dungeon.json.groovy.
Inside of your groovy script, you are given several arguments, and must return a value which will replace the original
JSON file. Valid values to return include maps, where map keys must be strings and values may be
lists, maps, numbers, booleans, strings, or dates. In addition to normal groovy features, You have the following
variables at your disposal inside your script:
json - the original JSON file, parsed into a map
platform - either "quilt" or "forge", depending on which platform you are running on
override - a method which, if called, will cause any further scripts attempting to modify the same file to not run
Multiple scripts in different datapacks or resource packs can target the same file - they are ran in order from highest
priority (the "top" pack) to lowest priority (the "bottom" pack). If a script calls override(), no further scripts
will run.
Servers
Note: As the groovy scripts that JsonWrangler loads can execute arbitrary code, JsonWrangler will not load scripts
from server resource packs. If you wish to load scripts from a server resource pack, you will have to copy it as a local
resource pack first.
Examples
Changing the texture of an item
Placing the following file at assets/minecraft/models/item/apple.json.groovy will change the texture of the apple to
use the potato texture:
json?.textures?.layer0 = 'minecraft:item/potato'
return json
评论 0
登录后参与评分
还没有评论,来抢沙发吧