-
Notifications
You must be signed in to change notification settings - Fork 52
Basic ModLoading Setup
This Information is for Creating a mod using QModManager 4.0 and may not be 100% accurate for other versions.
Type of Project: Class Library (.NET Framework)
Version of .NET: .NET Framework 4.7.2
Your mod must define at least one "patching" method.
These are the methods that QModManager will invoke to get your mod running when the game loads.
To get started, reference the dll file QModInstaller.dll
located in your Game directory, under BepInEx\plugins\QModManager\QModInstaller.dll
The file QModInstaller.xml
is also available there and will provide Visual Studio with documentation tooltips for all the methods, classes, and fields provided by QModInstaller. You do not need to reference the XML directly. It is implicitly referenced when you add the dll to your project.
The custom attributes that tell QModManager how to load your mod can be found under the QModManager.API.ModLoading
namespace.
The main patching class (which should be static) must be in a namespace.
The initialization method in this class should have no parameters.
To designate your patching class you will need to assign it the [QModCore]
attribute which will tell QMM look here for the patch method.
Your actual initialization method inside this class must be assigned the [QModPatch]
attribute.
This patch method is where you will make your calls to SMLHelper or patch methods using HarmonyX, or any other set up your mod might require. See Libraries for more information about these tools.
NOTE: When using HarmonyX, the
0Harmony.dll
assembly can be found atBepInEx\core\0Harmony.dll
, as opposed to the game's[game]_Data\Managed
folder as in previous QModManager versions.
Example:
// Include this namespace to simplify the code below
using QModManager.API.ModLoading;
using HarmonyLib;
namespace MyMod
{
// Your main patching class must have the QModCore attribute (and must be public)
[QModCore]
public static class MyInitializerClass
{
// Your patching method must have the QModPatch attribute (and must be public)
[QModPatch]
public static void MyInitializationMethod()
{
// Add your patching code here
Harmony harmony = new Harmony("Your unique mods identifier");
harmony.PatchAll();
}
}
}
If there is something missing or ambiguous, please create an issue or contact us on the Subnautica Modding Discord using our tags:
- PrimeSonic:
@PrimeSonic#0667
- Metious:
@Metious#3682