Starbound

Starbound

More Craftable Blocks
bk3000 7 Mar, 2017 @ 12:14pm
Preventing errors with better patching
Lets take the aegisalore that generates this error
Could not apply patch from file /items/generic/crafting/aegisaltore.item.patch in source: ..\mods\more_craftableBlocks. Caused by: (JsonPatchException) Could not apply patch to base. (JsonPatchException) Could not apply operation to base. (TraversalException) No such key 'learnBlueprintsOnPickup' in pathApply("/learnBlueprintsOnPickup/-")

Here is the best way to prevent that. Take your existing patch here
[ { "op": "add", "path": "/learnBlueprintsOnPickup/-", "value": "aegisblock" } ]
and replace with something like this
[ [ { "op" : "test", "path" : "/learnBlueprintsOnPickup", "inverse" : true }, { "op" : "add", "path" : "/learnBlueprintsOnPickup", "value" : [] } ], [ { "op" : "add", "path" : "/learnBlueprintsOnPickup/-", "value" : "aegisblock" } ] ]

This is a versatile method. This uses patch batches by nesting everything in an extra array []
The value of this is that the failure of one batch won't cause another batch to fail. And failed "test" operations won't generate log errors either.

The first batch tests for the existence of that path. But the "inverse" : true reverses the condition - which means it is testing for the lack of that path. If that condition is satisfied, it then adds the path, with a blank array as the value. If some other mod already added the path, this will not do so.

The second part is what you already had. It adds the "aegisblock" to the end of the array. Only now there is certainly an array to add to!

In the event that you are trying to keep this mod working with another mod(that doesn't use this method of patching) - but you don't require that mod necessarily - it would be best if this mod loaded after the other. You can accomplish this in _metadata like so.

"includes" : [ "someMod", "someOther_mod", "etc" ]
You use the actual mod's "name" string of course.

If you have any questions, I'd be glad to help.
Last edited by bk3000; 7 Mar, 2017 @ 12:17pm
< >
Showing 1-3 of 3 comments
bk3000 7 Mar, 2017 @ 12:35pm 
Also an unrelated thing, but I recommend to register your materialIds here.
http://starbounder.org/Modding:Materials:Mods
It helps mod makers avoid conflicts.
Capt_harbl  [developer] 27 Mar, 2017 @ 7:29pm 
Thanks for letting me know, I've given up on trying to keep things updated since CF tends to just break mods every update. If anyone wants to use my assets they can, just let me know.
bk3000 28 Mar, 2017 @ 1:31am 
Originally posted by Capt_harbl:
Thanks for letting me know, I've given up on trying to keep things updated since CF tends to just break mods every update. If anyone wants to use my assets they can, just let me know.

Hmm might take you up on that. I'm updating the old "hull plating blocks and more" mod. Lots of blocks but also objects. The functional update phase is done. All I really need to do at this point is (lots of) recipes fixes and refinement. Well also new content to match changes in vanilla Starbound since it was alive, but that can wait.

Would you find it acceptable if rolled your mod into it upon re-release? Of course I can credit you as well. Probably I'd just direct-copy to keep the block IDs the same/prevent problems for people using your mod now. But I do want to make sure you find that is an acceptable usage of your assets.
< >
Showing 1-3 of 3 comments
Per page: 1530 50