Skip to content

Adding crafting recipes for other mods items

MrPurple6411 edited this page Jul 27, 2020 · 1 revision

If you haven't looked at Using items from other mods yet, you probably should do that first since it explains how this is all possible in the first place. Remember, as a courtesy, check with the mod's author and make sure they're cool with you incorporating part of their work into your mod.

Getting Cross-Mod TechTypes


Any crafting node needs a TechType to identify what it's going to craft. In the case of a cross-mod TechType being added to your crafting tree, you only need the internal name it was registered with. There's a couple of ways you can get this:

  • Ask the mod's author
  • Check the mod's source code and look at what they used in the TechTypeHandler.AddTechType call.
  • Open the TechTypeCache.txt file and look for it. Obviously you'll need to have this mod installed yourself.

Once you have the cross-mod TechType's internal name, you can use it to add that item to a crafting tree your mod is handling.


AddModdedCraftingNode

Normally, you wouldn't be adding another mod's item to one of the standard crafting trees, so we'll skip that for now and go straight to the more typical example.

If you are creating a fully custom crafting tree, likely you are adding this to a new custom fabricator, then you will have access to a method to add items from other mods.

Root nodes and Tab nodes for a ModCraftTree both inherit from the ModCraftTreeLinkingNode class. As such, they both offer this method:

public void AddModdedCraftingNode([string] moddedTechTypeName)

Consider this method somewhat of a "TryAdd" method.
If the cross-mod TechType associated to that internal name exists, it will be adding to the crafting tree.
If it doesn't exist, meaning the player does not have the other mod installed, then this method will quietly do nothing and the craft node won't be added to the craft tree.

You would use it somewhat like this.

// node could be either the root node or any tab node in your craft tree.
node.AddModdedCraftingNode("WarpCannon");

This is a great way to add extra functionality across mods, making for a more unified experience.