Skip to content

Pre Patches

quipsol edited this page Nov 2, 2026 · 4 revisions

Pre-Patches are Harmony patches applied before the game starts. They are used to modify the game's behavior at a very early stage, allowing for changes that affect the game's initialization process.

This is important to modify anything that must change when the game runs through the editor-player. Either due to it happening before mods are loaded, or because it fixes a bug that explicitly exists in the editor-player and not when running the game normally.

Pre-Patches are not stored in your project, but inside the MoDot installation. You can toggle them on or off in the editor under Project Settings -> Pre-Patches.

Enabled pre-patches are stored in the project.godot file under the [editor] section.

pre_patches/enabled=PackedStringArray("modot.baselib.modeldbpreload", "modot.native.separateprojectmods", "modot.native.releaseinfo", "modot.native.separateprojectprofiles")

MoDot also supports pre-patching via the command line. Use --pre-patch followed by the assemblies you want to touch.

MoDot.exe --path "D:/Projects/MyMod" \
  --pre-patch "C:/path_to_modot_installation/pre_patches/Modot.Native.ReleaseInfo/modot.native.releaseinfo.dll"

The rest of this page explains the following:

Patches shipped with MoDot

Separating Mods by Project

Since the game starts through the Modot.exe, it assumes that as the source of mods. This means that if you have multiple projects, the game will load all mods from all projects, which is not what you want.

With this enabled, the games mod loading behaviour is changed to only load mods from specific subdirectories of the mods folder:

  1. _Always - mods that are always loaded, regardless of the project. Usefull for common libraries.
  2. <ProjectName>Mods - mods that are only loaded when that project is active.

Separate Profiles by Project

Similar issue to above, but with profiles. The game will load the same profiles for all projects. This means that if you switch between projects, you may override profile data from another.

For example: If you have an active run with a Character mod, and then you switch to a diffferent project with a different Character mod: The game will notice the old mod missing, hide the Continue run button, and asks you to start a new run. Doing so will override the curent_run.save. You will lose your progress with the first mod, and the second mod takes its place.

To prevent this, the pre-patch changes the profile loading behaviour to save and load profiles from a specific subdirectory of the saves folder named <ProjectName>Profiles. These profiles are new so you will have to unlock all in them.


Release Info

Slay the Spire stores its release_info.json next to the pck and not in it. Some may rely on it (e.g. RitsuLib) to work properly.

This pre-patch makes sure the ReleaseInfoManager loads the json from outside the pck.

Any json directly next to the MoDot installation wins, after that it walks past all mounted pcks and stops at the first found.


BaseLib ModelDb Preload

BaseLib initializes part of its systems in a Harmony Postfix to ModelDb.Preload(). This Preloading is skipped when running the game through the editor-player. This patches forces ModelDb.Preload() to run when the game is started through the editor-player, ensuring that BaseLib's systems are properly initialized.

While this does happen after the game has loaded mods, it is still an editor exclusive issue that will arise in many mod projects.

Making your own Pre-Patches

Making your own pre-patches is very simple. When MoDot starts the editor-player, after it loaded the mounted dlls, it will apply any active pre-patches.

It does so by touching the dll and force ModuleInitializer to run.

Here is the entire code for the BaseLib ModelDb Preload pre-patch:

using HarmonyLib;
using MegaCrit.Sts2.Core.Helpers;
using MegaCrit.Sts2.Core.Models;
using System.Runtime.CompilerServices;

namespace modot.baselib.modeldbpreload;

[HarmonyPatch]
public class Entry
{
	private const string ID = "modot.baselib.modeldbpreload";

	[ModuleInitializer]
	internal static void Init() => new Harmony(ID).PatchAll();

	[HarmonyPatch(typeof(OneTimeInitialization), nameof(OneTimeInitialization.ExecuteDeferred))]
	[HarmonyPostfix]
	private static void ForcePreloadInEditor() => ModelDb.Preload();
}

Pre-Patches are stored next to the MoDot.exe in the pre_patches folder. You can add your own pre-patches by creating a new folder and placing your compiled dll inside it.

Additionally, MoDot finds pre-patches not through scanning for dlls, but through the pre_patch_manifest.json files. Make sure you add this file next to your dll.

Its content looks like this:

{
  "id": "modot.baselib.modeldbpreload",
  "name": "BaseLib - ModelDb.Preload - fix",
  "assembly": "modot.baselib.modeldbpreload",
  "author": "Quipsol",
  "version": "v1.0.0",
  "description": "Fixes a BaseLib issue where due to game optimization differences between editor-player and build game, BaseLib would not run some setup."
}

Make sure the id is unique and that assembly matches the name of your dll without the extension. The rest are for display purposes in the editor.

You can name them whatever you want. I loosely went with <source>.<target>.<purpose>.`

Clone this wiki locally