
JSON Patches lib
Implements more convinient syntax and more functionality for patching JSON assets.

Description
<span style="font-size: 18pt;">Implements new syntax features for JSON patches.</span>
<span style="font-size: 14pt;">No idea if someone else will want to use it, but I for sure will use it to reduce the amount of time and effort I spend on JSON patches.</span>
<span style="font-size: 14pt;">Feel free to provide feedback and feature requests. If the lib will be popular, it will have a good change to be integrated into vanilla in 1.23.</span>
<span style="font-size: 18pt;">Documentation:</span>
[ { "enabled": true, // same as vanilla, if not enabled patch is ignored "priority": 0, // all json patches are applied in the order from highest to lowest priority, default is 0, use it to patch other patches by setting higher priority "op": "add", // operation, not case-sensitive, same as vanilla json patches, possible values: "Add", "AddEach", "AddMerge", "Replace", "Remove", "Copy", "Move", "Expression" "file": "game:itemtypes/snowball", // asset location of json file you want to patch, supports wildcard and regexes, to use wildcards add @ in the beginning of the path, to use regexes add @@, the path is matched as whole with domain in these cases "path": "attributes/shelvable", // path inside json, like vanilla, but with additional features: // - wildcard support: "texturesByType/@@snowball-/normal2" // - regex support: "texturesByType/@@@snowball-(snow|beenade)/normal2" // - property matching: "variantgroups/code=rock/states" // - range matching: "variantgroups/0-2/states/0-1" // - index matching: "variantgroups/0/states/1" // - all indexes matching: "variantgroups/-/states/-" // Each type of matching is applied inside a single path element (path between two closest '/') "fromPath": "attributes/shelvable", // same as 'path' "side": "universal", // same as vanilla, side where patch will be applied, possible values: "client", "server", "universal" "value": 0, // same as vanilla, used to add or replace a value, unlike vanilla can be used with 'remove' operation to match and element to remove (supports wildcards and regexes via '@@' and '@@@' prefixes) "dependsOn": [{"modId": "game", "invert": false}], // same as vanilla, used to enable/disable patch based on which mods are loaded } // unlike vanilla patches do not support 'conditions', that are meant to be used with world config ]</pre> <span style="font-size: 14pt;">Put patches into 'jsonpatches' folder, same as vanilla patches are put into 'patches' folder. Patches from this library are applied before vanilla patches, so you can patch vanilla patches. Patches from this lib can have priority specified, that allows to patch them (just specify priority higher than of the patch you want to patch).</span>
<span style="font-size: 18pt;">Examples:</span>
[ {"enabled": true, "file": "game:config/traits", "op": "replace", "path": "/code=soldier/attributes/armorWalkSpeedAffectedness", "value": -0.5}, {"enabled": true, "file": "game:config/traits", "op": "addmerge", "path": "/code=soldier/attributes", "value": {"armorManipulationSpeedAffectedness": -0.5}}, {"enabled": true, "file": "game:config/traits", "op": "addmerge", "path": "/code=soldier/attributes", "value": {"armorHungerRateAffectedness": -0.5}}, {"enabled": true, "file": "game:config/traits", "op": "remove", "path": "/code=soldier/attributes/meleeWeaponsDamage"}, {"enabled": true, "file": "game:config/characterclasses", "op": "remove", "path": "/code=blackguard/traits/-", "value": "nearsighted"}, { "enabled": true, "file": "game:config/characterclasses", "op": "addeach", "path": "/code=blackguard/traits/-", "value": ["meleeExpert", "oneHandedSwordsProficiency", "twoHandedSwordsProficiency", "poleaxeProficiency", "tremblingAim", "clumsyHands", "canParryProjectiles", "legDay"] } ]</pre> [ { "enabled": true, "side": "server", "op": "add", "file": "@game:itemtypes/toolhead/.json", "path": "creativeinventory/jsonpatches", "value": [] }, { "enabled": true, "side": "server", "op": "addeach", "file": "@@game:itemtypes/toolhead/.+.json", "path": "creativeinventory/jsonpatches/-", "value": ["-gold", "-silver"] }, { "enabled": true, "side": "server", "op": "addmerge", "file": "@game:itemtypes//arrowhead.json", "path": "creativeinventory/jsonpatches", "value": ["-copper", "-iron", "-steel"] }, { "enabled": true, "side": "server", "op": "add", "file": "game:itemtypes/toolhead/arrowhead.json", "path": "creativeinventory/temp", "value": [] }, { "enabled": true, "side": "server", "op": "copy", "file": "game:itemtypes/toolhead/arrowhead.json", "frompath": "creativeinventory/jsonpatches/4", "path": "creativeinventory/temp/-" }, { "enabled": true, "side": "server", "op": "move", "file": "game:itemtypes/toolhead/arrowhead.json", "frompath": "creativeinventory/jsonpatches/3", "path": "creativeinventory/temp/-" }, { "enabled": true, "side": "server", "op": "move",Ratings & reviews
Sign in to leave a rating or comment.
