Jump to content

Recommended Posts

Posted

Let's say I want to make it so that when a bed is destroyed, the corresponding soil drops. In the farmland.json file, the ‘drop’ section is empty. Okay, let's look at the corresponding section in soil.json and get it from there. Result:

FarmlandToSoil.zip/\assets\game\patches\farmland.json 

[
  {
    "file": "game:blocktypes/soil/farmland.json",
    "op": "replace",
    "path": "drops",
    "value": [ {
        type: "block",
        code: "soil-{fertility}-none",
        quantity: { avg: 1, var: 0 }
    } ]
  }

And nothing works. What's more, an error appears when loading the game:

8.8.2025 11:27:32 [Error] Patch 0 (target: game:blocktypes/soil/farmland.json) in game:patches/farmland.json failed, following Exception was thrown:
8.8.2025 11:27:32 [Error] Exception: The parent is missing.
   at JsonPatch.Adaptors.BaseTargetAdapter.ApplyOperation(Operation operation)
   at Tavis.PatchDocument.ApplyTo(IPatchTarget target)
   at Vintagestory.ServerMods.NoObf.ModJsonPatchLoader.ApplyPatch(Int32 patchIndex, AssetLocation patchSourcefile, JsonPatch jsonPatch, Int32& applied, Int32& notFound, Int32& errorCount) in VSEssentials\Loading\JsonPatchLoader.cs:line 354

 

Posted

   Oh! I figured it out! It turns out that everything works if you change it to this code:

 "op": "add",
    "path": "/drops",

But can you tell me what was wrong with the first code? Was it because of the "/" character?

 

P.S. And one more thing. Game resources have the prefix "game:" (for example, "game:blocktypes/soil"). At the same time, the "Vintagestory\assets\game\" folder contains almost no .json files, and almost all of them are located in the "survival" directory. Why is this so illogical?

Posted
6 minutes ago, ChimMAG said:

But can you tell me what was wrong with the first code? Was it because of the "/" character?

Yes. Paths always start with a forward slash.

8 minutes ago, ChimMAG said:

P.S. And one more thing. Game resources have the prefix "game:" (for example, "game:blocktypes/soil"). At the same time, the "Vintagestory\assets\game\" folder contains almost no .json files, and almost all of them are located in the "survival" directory. Why is this so illogical?

The prefix "game" is a domain and includes all Vanilla folders (creative, game, survival). It's a link, not related to the general assets of Vintage Story, used by all game modes and the game itself (GUI, fonts, etc), which are stored in the "game" folder.

Posted

Okay, thank you, I understand.

 

I looked at the file blocktypes\soil\farmland.json - there is no mention of the current fertilizer content in the block. There is ‘fertilityByType’, which sets the maximum fertilizer level, but that's obviously not it. This information is probably located in the properties of the ‘BlockFarmland’ class. Can this information be saved when the block is destroyed?

Posted
18 minutes ago, ChimMAG said:

Okay, thank you, I understand.

 

I looked at the file blocktypes\soil\farmland.json - there is no mention of the current fertilizer content in the block. There is ‘fertilityByType’, which sets the maximum fertilizer level, but that's obviously not it. This information is probably located in the properties of the ‘BlockFarmland’ class. Can this information be saved when the block is destroyed?

This has to be done via code. I'd have a look at https://mods.vintagestory.at/farmlanddropssoil and https://mods.vintagestory.at/farmlanddropswithnutrients to see how the mod authors did it. That's way beyond my current league.

Posted

You're probably right, although I thought that if I didn't average the amount of fertiliser, but instead recorded each block of the garden bed's own value (yes, they won't be combined and each block will occupy a separate inventory slot, but that's not a bad thing either), then I could do without the code. Thank you very much.

  • 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.