Closed copygirl closed 6 years ago
Feel like fixing that @copygirl? It's this lib: https://github.com/tavis-software/Tavis.JsonPatch
It appears the "add"
operator does not work at all. The following patch:
[
{ file: "game:blocktypes/clay/bowl", op: "replace", path: "/variantgroups/0/states", value: ["raw", "burned", "honey", "soup"] },
{ file: "game:blocktypes/clay/bowl", op: "add", path: "/shapeByType/*-soup", value: { base: "game:block/clay/bowl-ground" } },
{ file: "game:blocktypes/clay/bowl", op: "add", path: "/texturesByType/*-soup", value: { content: { base: "block/cauldron/cauldroninside" } } },
{ file: "game:blocktypes/clay/bowl", op: "add", path: "/nutritionPropsByType/*-soup", value: {
saturation: 400,
health: 1,
eatenStack: { type: "block", code: "game:bowl-burned" }
} },
]
produces the following errors:
21.3.2018 18:54:25 [Error] Patch cauldron:patches/bowl.json: Patching of file game:blocktypes/clay/bowl.json failed because supplied path /shapeByType/*-soup is invalid: Cannot traverse beyond depth 1. Token *-soup was not found
21.3.2018 18:54:25 [Error] Patch cauldron:patches/bowl.json: Patching of file game:blocktypes/clay/bowl.json failed because supplied path /texturesByType/*-soup is invalid: Cannot traverse beyond depth 1. Token *-soup was not found
21.3.2018 18:54:25 [Error] Patch cauldron:patches/bowl.json: Patching of file game:blocktypes/clay/bowl.json failed because supplied path /nutritionPropsByType/*-soup is invalid: Cannot traverse beyond depth 1. Token *-soup was not found
Is this still an issue @copygirl?
Nope, from what I know and have tested it should work now!
According to RFC 6902 linked in the 1.5.2 release post, inserting into arrays should be possible. This is kind of important if the order matters, which can be the case for block behaviors, for example
Example patch
File:
assets/carrycapacity/patches/carryable.json
Workaround
Can replace the entire array for now: