DArkHekRoMaNT Posted October 24, 2020 Report Posted October 24, 2020 (edited) Embedded in vanilla since 1.15.0, do not use the library as mod in later versions, the game will crash.All functionality is preserved, so nothing will change for mod authors other than library dependency. A simple library for Vintage Story that makes it easy to add compatibility with other mods for assets. Easy way Spoiler You just need to add your asset to assets/<yourmodid>/compatibility/<othermodid>/<vanilla-path>. They will only be loaded if <othermodid> is loaded. For example: I have a More Variants mod (modid - morevariants), I want to add a patch to support Carry Capacity (modid - carrycapacity) and add recipes for Extra Chests (modid - extrachests). As a result, the assets will look like this: assets morevariants blocktypes patches recipes compatibility carrycapacity patches carryable.json betterchests recipes grid copperchest.json copperlabeledchest.json P.S. If assets/<yourmodid>/<vanilla-path> and assets/<yourmodid>/compatibility/<othermodid>/<vanilla-path> exists then if <othermodid> is loaded, the first asset will be replaced. Advanced (v1.2+) Spoiler You can use dependsOn[] in json-patch for create mod-dependent patch. For example: dependsOn[{"modid": "morerecipes"}] - loaded if enabled morerecipes mod dependsOn[{"modid": "morerecipes", "invert": true}] - loaded if disabled morerecipes mod dependsOn[{"modid": "morerecipes"}, {"modid": "captureanimals"}] - loaded if enabled morerecipes AND captureanimals mods dependsOn[{"modid": "morerecipes"}, {"modid": "captureanimals", "invert": true}] - loaded if enabled morerecipes AND disabled captureanimals Warning! Unlike the easy way, if you use mod-dependent patches, it is advisable to add compatibilitylib in the mod dependencies, otherwise all patches will be loaded without the library installed. How to add to modinfo.json: { "modid": "bestmod", <...> "dependencies": { "game": "1.13.4", <-- minimal game version for your mod "compatibilitylib": "1.2.0" <-- minimal CL version } } Full patch example: [ { "_comment": "If you add enabled: false to your recipe, you can simply enable it when the desired mod is loaded", "file": "recipes/grid/best-other-fish-recipe.json", "op": "replace", "path": "/enabled", "value": true, "dependsOn": [{ "modid": "primitivesurvival" }] }, { "_comment": "Otherwise, just disable the recipe when the mod is not loaded", "file": "recipes/grid/best-fish-recipe.json", "op": "add", "path": "/enabled", "value": false, "dependsOn": [{ "modid": "primitivesurvival", "invert": true }] }, { "_comment": "Or when two mods are loaded :P", "file": "recipes/grid/best-fish-recipe-with-acorns.json", "op": "replace", "path": "/enabled", "value": true, "dependsOn": [ { "modid": "primitivesurvival" }, { "modid": "acorns" } ] }, { "_comment": "For simplicity, you can patch all recipes in a folder at once with *", "file": "recipes/grid/morerecipes-disable/*", "op": "add", "path": "/enabled", "value": false, "dependsOn": [{ "modid": "morerecipes" }] } ] Download: ModDB or GitHub Install as a regular mod, just add archive to your mods folder. Edited July 19, 2021 by DArkHekRoMaNT embedded warning 4 4
Bladimiro Herrero Posted October 25, 2020 Report Posted October 25, 2020 This is going to simplify things so much!
DArkHekRoMaNT Posted November 10, 2020 Author Report Posted November 10, 2020 v1.1: Improved code and behavior when the same asset exists.
DArkHekRoMaNT Posted November 27, 2020 Author Report Posted November 27, 2020 (edited) Works on 1.14.0-rc.4 as is. Edited November 27, 2020 by DArkHekRoMaNT
DArkHekRoMaNT Posted December 7, 2020 Author Report Posted December 7, 2020 4 hours ago, xCoiotex said: does it works on 1.14.0 release? Haven't tested but should work. It is very difficult to break this library anyway. This is a very simple code))
Minnigin Posted December 7, 2020 Report Posted December 7, 2020 5 hours ago, xCoiotex said: does it works on 1.14.0 release? seems fine so far
Sukotto82 Posted December 21, 2020 Report Posted December 21, 2020 so would this work with my Clay+Misc mod or do I need to finish cleaning it up and replacing everything in a more traditional mod form to work? right now it's only released as it is made using the mod maker provided by VS and as result it doesn't transfer textures so I opened the mod zip it created and added the texture folder manually, other than that it is however the mod maker makes it. I haven't gotten any feed back so I don't know if my mod even works for other people as of right now. it works for me but that's because I have the original JSON that I added in the vanilla Roaming > Vintagestory > assets > survival folder and everything is working on my end except the poring of the saw mold and I'm working on that. I'll be re-writing the whole thing in a proper mod folder using the game: reference line and everything but right now it's being hard to make work that way. it works best right in the folders themselves but I'm still learning and working on it. I wish it was as easy as modding 7 days to die and simply have a UIAtlases for my textures and a mod folder with <mymodname> <append xpath="/items"> put all the new items I want to add between here then close it with </append> </mymodname> this would be so much easier but this whole JSON thing is new to me and I'm still trying to figure it out.
DArkHekRoMaNT Posted December 21, 2020 Author Report Posted December 21, 2020 (edited) 2 hours ago, Sukotto82 said: Roaming > Vintagestory > assets > survival Don't do this, it will NOT work for other people. Put this file in assets/game in your mod folder. But in general, the library just looks at the assets in the compatibility category and checks for the modid in the list of loaded mods. This should work for vanilla too. Edited December 21, 2020 by DArkHekRoMaNT 1
jakecool19 Posted January 24, 2021 Report Posted January 24, 2021 This is absolutely brilliantly and works really nicely. I will definitely be using it more for future projects.
Yvette Forty Posted January 31, 2021 Report Posted January 31, 2021 Okay, I have a lot of mods now and would like a few more but need this, but have been avoiding this because I don't understand this. I have only ever been a designer and dabbled in flash animation a long while ago but am better at graphics than code. So I can't comfortable use something I don't understand. So, can I get a step by step for dummies on how to use this and when to use this mod and what you use and where the assets might be? Sorry...
DArkHekRoMaNT Posted January 31, 2021 Author Report Posted January 31, 2021 @Yvette Forty this is a library for mod devs, usually authors indicate if required. All the player needs to do is just add it to the mods folder like a regular mod.
DArkHekRoMaNT Posted February 21, 2021 Author Report Posted February 21, 2021 v1.2.0: Added Harmony patch for use dependsOn in json-patches (see readme or first post for more info) 1
DArkHekRoMaNT Posted February 21, 2021 Author Report Posted February 21, 2021 v1.2.1: Fixed inverted skip and skip by default
Xandu Posted March 1, 2021 Report Posted March 1, 2021 Hey. I tried some things with your mod and the 'dependsOn ' but couldn't get the 'invert' to work. So i looked at the source code of your mod and noticed that in the ModJsonPatchLoaderPatch.cs file the line 108 is: flag = flag && (loaded & !dependence.invert); But doesn't that mean that it will be false whenever loaded ís false? So it is not inverted. Shouldn't it be something like: flag = flag && (loaded ^ dependence.invert); For an exclusive or. Or do I get something wrong and don't understand how it's supposed to work? 1
DArkHekRoMaNT Posted March 1, 2021 Author Report Posted March 1, 2021 Thanks, fixed. Apparently I broke it when I was fixing patches that didn't work at all
DArkHekRoMaNT Posted March 1, 2021 Author Report Posted March 1, 2021 (edited) v1.2.2: Fixed invert Edited March 1, 2021 by DArkHekRoMaNT 1
Tyron Posted June 10, 2021 Report Posted June 10, 2021 Thanks for putting your code under MIT license. This mod is now integrated into the vanilla game by v1.15-pre.4 2 2 4
Recommended Posts