Jump to content

Recommended Posts

Posted

I'm trying to make a compatibility patch between my mod and the mod "The Remnants", but I'm having some trouble and wondering if anyone can help me.

The problem seems to be coming from this file in the remnants mod, a patch to plant-leaves-normal in "assets > game > patches". It's trying to do something to the drops of the leaves, but because my mod adds a new drop to the start of the drops list for leaves, it ends up targeting the wrong drops. The full text of the remnants patch that's causing trouble is:

[
  {
    "op": "add",
    "path": "/drops/0/quantityByType/dropModbyStat",
    "value": "treeseedDropRate",
    "file": "blocktypes/plant/leaves/normal.json"
  },
  {
    "op": "add",
    "path": "/drops/1/dropModbyStat",
    "value": "stickDropRate",
    "file": "blocktypes/plant/leaves/normal.json"
  }
]

So I'm trying to make a patch to this patch that will move what drops it's targeting down - so it's targeting /drops/1 and /drops/2 instead of 0 and 1. My patch is located in "assets > decor-ice-leaves > compatibility > theremnants > patches" and looks like this:

[
  {
    "op": "replace",
    "path": "/0",
    "value": {
		"op": "add",
		"path": "/drops/1/quantityByType/dropModbyStat",
		"value": "treeseedDropRate",
		"file": "blocktypes/plant/leaves/normal.json"
	}
    "file": "theremnants:patches/survival-blocktypes-plant-leaves-normal"
	"dependsOn": [ { "modid": "theremnants" } ]
  },
  {
    "op": "replace",
    "path": "/1",
    "value": {
		"op": "add",
		"path": "/drops/2/quantityByType/dropModbyStat",
		"value": "stickDropRate",
		"file": "blocktypes/plant/leaves/normal.json"
	}
    "file": "theremnants:patches/survival-blocktypes-plant-leaves-normal"
	"dependsOn": [ { "modid": "theremnants" } ]
  }
]

But it isn't working. In addition to the regular error of our two mods conflicting, I'm also getting this other error in the logs about how my patch isn't working:

7.3.2025 16:15:11 [Error] Failed loading patches file decor-ice-leaves:compatibility/theremnants/patches/survival-blocktypes-plant-leaves-normal.json:
7.3.2025 16:15:11 [Error] Exception: Failed deserializing survival-blocktypes-plant-leaves-normal.json: After parsing a value an unexpected character was encountered: ". Path '[0].value', line 11, position 4.
   at Vintagestory.Common.Asset.ToObject[T](JsonSerializerSettings settings) in VintagestoryLib\Common\Model\Asset.cs:line 67
   at Vintagestory.ServerMods.NoObf.ModJsonPatchLoader.ApplyPatches(String forPartialPath) in VSEssentials\Loading\JsonPatchLoader.cs:line 212

Can anyone help? I'm still a total noob at modding and this is my first time trying to make a compatibility patch.

Posted (edited)
1 hour ago, Lucas Alexander said:

My patch is located in "assets > decor-ice-leaves > compatibility > theremnants > patches"

You are trying to patch a patch, which is not recommended, for reasons you already discovered.

As far as I understand overwriting files isn't possible with the compatibility lib. Rather, it seems to add to (or as stated on the wiki, "rewrites") the files.

I looked at your leafPatch and see a much easier way. Simply replace "/drops/0" with "/drops/-". This way your drop will be added to the end of the array and compatibility is achieved (which generally should be done for this exact reason). Because you specified a tool in your drop, you'll still get your leaves when you use a saw on leaves.

Edited by Brady_The
  • Like 1
Posted

@Brady_The

I did think of this, but the problem is I'm also using "LastDrop": "True" in my patch. My understanding of how this works is that the game looks through the list of drops in order and, if it finds a drop with "LastDrop": "True", it won't drop anything beyond that. This is important because I don't want people to be able to farm leaves for infinite sticks and seeds if they use my mod - if they get a leaf block drop by using a saw, they shouldn't also be able to get regular leaf blocks on top of that.

I was thinking about other ways to solve this issue though, and I was wondering if there is a way to change the load order? If I could get The Remnants mod to load before mine, so it applies it's patch first and then applies mine, I think it would solve the issue.

Posted
7 hours ago, Lucas Alexander said:

@Brady_The

I did think of this, but the problem is I'm also using "LastDrop": "True" in my patch. My understanding of how this works is that the game looks through the list of drops in order and, if it finds a drop with "LastDrop": "True", it won't drop anything beyond that. This is important because I don't want people to be able to farm leaves for infinite sticks and seeds if they use my mod - if they get a leaf block drop by using a saw, they shouldn't also be able to get regular leaf blocks on top of that.

True enough, I didn't think of that. The Compat Lib article on the wiki is very weirdly written, sending mixed messages on patching patches.

7 hours ago, Lucas Alexander said:

I was thinking about other ways to solve this issue though, and I was wondering if there is a way to change the load order? If I could get The Remnants mod to load before mine, so it applies it's patch first and then applies mine, I think it would solve the issue.

There is. Potentially. The load order seems to be based on folder/zip-file names. Changing "DecorativeLeavesAndIce" to "sDecorativeLeavesAndIce" should load it after "Remnants". But that doesn't always seem to be the case. Out of curiosity I did a small test and got back this result:

Quote

External Origins in load order: modorigin@E:\Vintagestory\assets\creative\, modorigin@E:\Vintagestory\assets\survival\, mod@bradycrackedrock-v1.0.1_v1.20.x, mod@bradyladders-v1.0.1_v1.20.x, mod@brady_music, mod@PatchDebug-1.1.2.zip, mod@Remnants 1.0.3, mod@sDecorativeLeavesAndIce, mod@bradycrudebuilding-v1.3.0_v1.20.4

So for reasons unknown there appear to be exceptions from this "rule".

With my limited knowledge of Vintage Story modding, my current solution would be this (branchy would need this treatment too, of course):

Spoiler
[
	{
		"file": "game:blocktypes/plant/leaves/normal",
		"op": "addmerge",
		"path": "/drops/0",
		"value": {
			"type": "block",
			"code": "game:leaves-placed-{wood}",
			"quantity": { "avg": 1 },
			"tool": "saw",
			"LastDrop": true
		},
		"dependsOn": [ { "modid": "theremnants", "invert": true } ]
	},
	{
		"file": "game:blocktypes/plant/leaves/normal",
		"op": "addmerge",
		"path": "/drops/-",
		"value": {
			"type": "block",
			"code": "game:leaves-placed-{wood}",
			"quantity": { "avg": 1 },
			"tool": "saw"
		},
		"dependsOn": [ { "modid": "theremnants" } ]
	}
]

It's not the most ideal solution, but if somebody is using The Remnants in combination with your mod, having to place and replace hundreds of leave blocks to farm drops one could acquire much faster with a run through the forest or by opening the Creative menu, is in my opinion preferable over the breaking of another mod. (Renaming my .zip-file to influence load orders isn't an option for me, but maybe you don't mind. There really should be a better way to influence the order.)

You most likely would be able to do something with code, but a) unfortunately I can't code and b) I think this would be slightly out of scope for this mod. Of course you could also ask on the forum killer Discord for a better way. The VS server is much more lively than the forum.

  • Thanks 1
Posted

@Brady_The

Thanks a bunch for the help! I ended up renaming the file to zDecorativeLeavesAndIce and that seems to have gotten rid of the conflict. I think it's a sensible solution anyway, since my mod is supposed to be pretty light weight so it makes sense that it would be near the bottom of the load order. That being said, I will keep a look out and see if anyone else has any problems with it, if there are exceptions to the load order rule like you said.

The whole infinite sticks/leaves exploit really isn't that big of a deal, it's more how it breaks my immersion that bothers me more than the ability to farm infinite items using a saw and some leaves.

And again, seriously, thank you for all the help. You've responded to a lot of my posts with really detailed and useful answers, you've been an absolute lifesaver more time than I can count.

  • Thanks 1
Posted
2 minutes ago, Lucas Alexander said:

The whole infinite sticks/leaves exploit really isn't that big of a deal, it's more how it breaks my immersion that bothers me more than the ability to farm infinite items using a saw and some leaves.

I can see that. Sometimes reality gets in the way of ambition, though. Haha

3 minutes ago, Lucas Alexander said:

And again, seriously, thank you for all the help. You've responded to a lot of my posts with really detailed and useful answers, you've been an absolute lifesaver more time than I can count.

Cheers! We are all together in this modding endeavour and the learning processes. 😄

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