Jump to content

Recommended Posts

Posted

I've been trying to understand how to get used to .json patching by modifying a mod with my own. i can't seem to get it to work correctly. can you help/show me what I'm doing wrong?

here is the file layout:

Mods\1 k9's-fixes\assets\k9's-fixes\patches\compatibility\floralzonesneozeylandicregion\blocktypes\plant\patched-nzflax.json

here is the code:

[
  {
    "file": "floralzonesneozeylandicregion:/blocktypes/plant/nzflax.json",
    "op": "replace",
    "path": "/dropsByType/*-phormiumtenax-*-harvested-*/quantity/avg",
    "value": 2,
    "side": "server",
    "dependsOn": [{ "modid": "floralzonesneozeylandicregion" }]
  }
]

i also have custom recipes added. so i know my mod kind of works.

Posted (edited)
1 hour ago, k9inpoop said:

can you help/show me what I'm doing wrong?

Hey there. Overall the patch looks good. You only got two small mistakes.

Quote

[
    {
        "file": "floralzonesneozeylandicregion:/blocktypes/plant/nzflax.json",
        "op": "replace",
        "path": "/dropsByType/*-phormiumtenax-*-harvested-*/0/quantity/avg",
        "value": 2,
        "side": "server",
        "dependsOn": [{ "modid": "floralzonesneozeylandicregion" }]
    }
]

You initiate the file reference after the domain with a slash, that prevents the patch from being applied. The server-debug log would have given you this error message:

Quote

Patch 0 in yourmod:patches/phormiumtenax.json: File floralzonesneozeylandicregion:/blocktypes/plant/nzflax.json not found

That's the reason why you wouldn't have seen any error messages in the server-main log, if you would have looked. Which btw, I can only recommend. Especially the client- and server-main.log files are a great tool to figure out if something is wrong and what it is.

Quote

[Error] Patch 0 (target: floralzonesneozeylandicregion:blocktypes/plant/nzflax.json) in yourmod:patches/phormiumtenax.json failed because supplied path /dropsByType/*-phormiumtenax-*-harvested-*/quantity/avg is invalid: The json path /dropsByType/*-phormiumtenax-*-harvested-*/quantity/avg was not found. Could traverse until /dropsByType/*-phormiumtenax-*-harvested-*, but then 'quantity' does not exist.

The next mistake happens in the path. Drops are always formatted as an array (identifiable by the square brackets [ ]). If you want to access an array, you have to address the array like any other key ("dropsByType", "*-phormiumtenax-*-harvested-*", "quantity", "avg"). You do that via their indices. Arrays start counting at 0, which in this case, is your harvested phormiumtenax. If you would have wanted to address the drops of the normal phormiumtenax you would have used "1" in the path instead.

Edited by Brady_The
  • Like 1
Posted
7 minutes ago, Brady_The said:

Hey there. Overall the patch looks good. You only got two small mistakes.

ahh.. thanks I've been reading up and looking at how everyone else was doing it. on one i saw your reply to it and tried my best to learn from that.

i did do the /0/ for a few edits still didn't know why it wasn't working at the time. i didn't see the extra slash in the file path at all.  i was wondering why the errror didn't show in the startup of the server.( i didn't check the debug log) thanks you're the best

  • Like 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.