Jump to content

Recommended Posts

Posted

I'm planning a mod that adds a new item, including some recipes to make it, and some recipes that require it. The new item is roughly equivalent to an item added by another mod.

To avoid duplication, if the other mod is installed as well, I want its version and my version of the item to be combined (or one to replace the other). But importantly, I want some of the other mod's recipes for the item to be removed from the game.

If the other mod is not installed as well, I still want my new item to be available with all the recipes that my mod adds.

What's the best way to achieve this? I could override the other mod's version of the item files and recipes, but then if the other mod isn't installed mine wouldn't work. Or I could add my item separately, but then if the other mod is installed there will be two versions of the same thing.

  • Solution
Posted (edited)

That's Compatibility Lib's moment to shine.

I am currently rewriting the article, because it is a bit archaic. Here's a sneak preview: https://wiki.vintagestory.at/BradyThe/Sandbox (It's still a work in progress, but hopefully explains the inner workings of the Comp Lib already a bit better.)

How I would go about it depends a bit on the structure of the other mod and your goals.

Remove recipes from the other mod: Easy. I would probably use Mod-dependent json-patches (JSON Patches in my rewrite) to disable them.
Combine/replace item: Easy - medium: There are one or two solutions to this.

  • Overwrite the 3rd-party item with the Comp Lib. Put all properties of both items (the 3rd-party and yours - combine) into this file. Disable your item via patch. Add recipes into the compatibility folder using the item code of the overwrite.
  • Disable the 3rd-party item with a patch, add any properties of the 3rd-party item you want in yours (combine) to your item by patch.

Example setup (I quickly frankensteined an existing test setup, pay no regard to any domain or other inconsistencies):

Spoiler

This is the default view with both items (3rd-party and yours) available:

3181_20I1vTbiLJtoCTK6aA91.png.f62a71b11619034f037082c078a4e5a2.png

This is the default view after overwriting the 3rd-party item with Comp Lib (notice how the 3rd-party item overwrite is in your mod domain):

3182_J2OdcoB3pEh2MtLjLVUp.png.63613da1f5f58a999f1f71cf0154162d.png

Spoiler

File setup:

3184_2iWFZ0Gs3jXCgkhri1Zp.thumb.png.e0da8c223c1e7d99dbafdba1f7723b0d.png

I hope all of this isn't too theoretical only making sense in my mind. If you have any questions, shoot them.

Edited by Brady_The
×
×
  • 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.