Closed Desymoo closed 1 year ago
Hi, sorry about not responding sooner. I actually only just now saw this (somehow I didn't get an email this time.)
Unfortunately, I'm not sure I understand what exactly you're trying to do here. Are you just trying to add an array to an array? If so, you can do the following:
{
"op": "add",
"path": "/path/to/my/array/-",
"value": [
1,
2,
3
]
}
Otherwise, it might help if you could provide a snippet of what you want to change as well as what it should look like after, and then I can try to come up with something.
No worries! Thank you for the response :)
There's some fairly convoluted arrays of arrays of arrays in certain Minecraft jsons (I'm specifically working with worldgen stuff) so it can get a little tricky trying to patch in new entries. I think specifically I was hoping to set the "value" field as a whole array of nested arrays, but I'm not sure that would be feasible here.
After some further thought, the easiest solution for my problem might be a marker that allows pathing down through the last index of an array. If I understand correctly, the end-of-array marker is only used for adding new things at the end of an array, right? So if I wanted to duplicate a nested array to the end of the parent array and then replace a few values within the duplicate, this wouldn't work:
{
"op": "copy",
"path": "/array/of/biome/arrays/-",
"from": "/array/of/biome/arrays/1"
},
{
"op": "replace",
"path": "/array/of/biome/arrays/-/0",
"value": "different grass color"
}
(Sorry if I'm doing a terrible job of explaining)
I'm still not entirely sure what you're trying to do. I tried looking for where grass colors are defined really anywhere in the worldgen jsons and didn't find anything that involved arrays. Could you make a gist containing the file you're editing and comment the link? Otherwise I guess I'm just not sure why the array needs to be copied instead of defined inline.
Is there any particular reason why it needs to be the last element in the array? If not, you could do something like the following:
[
{
"op": "add",
"path": "/array/of/biome/arrays/0",
"value": []
},
{
"op": "copy",
"path": "/array/of/biome/arrays/0",
"from": "/array/of/biome/arrays/2"
},
{
"op": "replace",
"path": "/array/of/biome/arrays/0/0",
"value": "different grass color"
}
]
Still though, I don't know why you need to copy the array and replace an element in it, so I think being able to see the file format would help.
Aha! Nope I was definitely just thinking myself in circles - there is in fact zero reason why it needs to be at the end of the array. Thank you so much for your help, I'm so sorry for eating up your time like that!
For clarification - the grass example wasn't anything specific. My actual goal was to insert new biome arrays into overworld.json in the minecraft/dimension folder and edit their temperature/humidity/etc to change the overall biome spread. I can't believe I didn't once think to just insert them at the top, big sigh.
Just wondering if this is possible yet with this framework :) I've been using the copy operation to copy an existing array and then replace the elements that I want to edit, but it's not the most reliable method.
Something like: