Skip to content

Instantly share code, notes, and snippets.

@Aragas
Last active March 15, 2023 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aragas/2ac05e41210babdd7043ec1820550be6 to your computer and use it in GitHub Desktop.
Save Aragas/2ac05e41210babdd7043ec1820550be6 to your computer and use it in GitHub Desktop.
Two Major Announcements for the Bannerlord's Modding Ecosystem

Two Major Announcements for the Bannerlord's Modding Ecosystem

Quick Summary for Players

We're releasing a new mod called BLSE that is an analogue of SKSE for Skyrim and we are releasing beta versions of the core modding mods for Bannerlord.
We expect a small number of mods to be broken by the betas. Our test show it's a really small percentage <10%, but big mod collections will be affected most likely!
Also, to be able to use mods on Game Pass PC you'll need to install BLSE and launch it instead of the original executables. On Steam/GOG/Epic BLSE will be optional for now.

Quick Summary for Modders

This article discusses two major announcements for the Bannerlord modding ecosystem.
The first announcement is the switch from Harmony to HarmonyX due to the introduction of a new game version based on .NET Core (Game Pass PC). HarmonyX is a drop-in replacement for Harmony that uses a different backend for patching the game.
The second announcement is the introduction of BLSE, a tool for Bannerlord mods that expands modding capabilities and adds additional functionality to the game. BLSE is compatible with both versions of the game, .NET Core and .NET Framework, and multiple versions of the game.
With BLSE we will also release the beta version of Harmony, UIExtenderEx, ButterLib and MCM. After a week they'll become the main versions.

Introduction

As you might know, Bannerlord is a game built on the .NET Framework (C#), using .NET Framework on Windows and Mono on Xbox and Playstation. Recently, Bannerlord introduced a new version based on .NET Core, a cross-platform C# runtime that offers more performance and works on Windows, Linux, and OS X.

Due to this significant change, we are making two major announcements for the Bannerlord modding ecosystem. First is the switch from Harmony to HarmonyX, and the second is the introduction of BLSE.

The Hidden Runtime

Bannerlord has had support for .NET Core for a long time, and we discovered it during the Early Access phase. The game was runnable with .NET Core 3 and newer versions, which was exciting. However, this also poses a significant challenge for modders.
At the time of writing this article, the latest released .NET version is 7, and 8 is on its way. However, .NET 7 is still not fully supported by Harmony and the underlying libraries due to new feature restrictions by .NET developers.

We hope that these restrictions can be lifted by Harmony and the underlying MonoMod.* and Mono.* libraries so that we can continue to enjoy .NET modding further. As players, the best thing we can do is to support the existence of these underlying libraries and their authors so that they can continue to work on something they love!
Also, a quick side note. We believe that the underlying libraries that are used for modding games deserve support and recognition. We started to sponsor those libraries on GitHub, Patreon and other services and we think it was a success. Even if the money isn't enough to provide full development time for the authors, every penny counts. So we ask the modding community to do the same! If your mod uses a library that has some sponsorship note, do support them! Only a healthy foundation can keep the game successful!

Solution X

Since discovering .NET Core support, we've been thinking about the future of modding. Generally speaking, when you create a mod for .NET Framework, it should be able to run on .NET Core, but we can't always develop by targeting .NET Framework and hope that it will work on .NET Core. A shared library target type called netstandard2.0 allows us to develop for both .NET Framework and .NET Core, but Harmony stopped supporting it.

While looking for possible solutions, we found HarmonyX, which is a drop-in replacement for Harmony that uses a different backend for patching the game. You can check HarmonyX's Wiki to get more info about the differences. It does have some behavior differences, and we tested them to find out that the majority of mods work correctly with HarmonyX. This means it won't introduce full chaos when released! As you might have noticed, this change hasn't been implemented yet. We believed that we could try to work something out with the original Harmony, but now that we have the Game Pass version released that uses .NET Core, the time has run out.

There are two other major considerations as to why we support HarmonyX:

  • It allows us to use a library called MonoMod.RuntimeDetours that introduces a different way to do patching that will be compatible with Harmony.
  • A technical issue with how the original Harmony distributes its dependencies. On .NET Framework, the dependencies are embedded within it, but on .NET Core, they are external. This is a major difference in behavior. With HarmonyX, they are always external. We have a workaround for .NET Framework that will allow existing mods that were compiled for Harmony to work with HarmonyX.

One Loader to Load Them All

We are excited to introduce BLSE, a major tool for Bannerlord.
Bannerlord Software Extender (BLSE) is a tool for Bannerlord mods that expands modding capabilities and adds additional functionality to the game.

Following the theme of mimicking the names of some of the best mods for Skyrim and other Bethesda games, we named it after SKSE and others alike.
We'd like to note that the renaming of Bannerlord.MBOptionScreen to MCM was a player-requested change. We didn't want to copy Skyrim blatantly, but to provide some common ground for players! After the renaming we decided that it could be an interesting thing to do with our next mods.

Didn’t We Had BUTRLoader Already?

Previously, we used BUTRLoader for a similar to a loader role. It hooked into the game as early as possible, using an unobtrusive injection technique. However, with the introduction of .NET Core, had the need to create our own executable to bootstrap the game and run it, instead of using a library that would be automatically hooked by .NET Framework. .NET Core doesn't support a similar technique. While this means that users will need to configure the game to be launched as a different executable, it is still unobtrusive, and no permanent changes will be made to the game.

BLSE is similar to BUTRLoader, but it is compatible with both versions of the game - .NET Core and .NET Framework - and multiple versions of the game, from v1.0.0 to v.1.1.0. We consider this a prime showcase of cross-compatibility support in Bannerlord and intend to continue this trend!

Support of Game Pass PC

It's also important to mention that the Game Pass version of the game is very restrictive, using its own bootstrapping process that needs to decrypt the game's .exe file to launch. However, using our own executable bypasses this. Unfortunately, this also means that Xbox profile features will not be available, as we do not intend to provide a workaround for that.

Why Should I Care?

We hope that with BLSE we can have more control over the game.
As prime examples of usage of BLSE, we added native support of Python modules with it's own SubModulePython tag that wouldn't be possible before.
BLSE also fixes assembly conflicts that are not possible to fix otherwise. Harmony and HarmonyX depend on mono.cecil >0.11.0. The game provides it's own version of 0.9.8 that will be prioritized when looking for the dependency. BLSE changes the dependency resolution by looking first for the dependencies in the /Modules folder, then in the game's root folder. There are other interesting features that you can checkout in the mods page like the support of continuing a specific save file.
It also has the fanciest Mod Id possible - 1

Conclusion

We hope that these two major announcements - the switch to HarmonyX and the introduction of BLSE - will make modding Bannerlord a more pleasant experience for modders and players alike, especially with the game's new version based on .NET Core!

As always, we want to thank the community for their continued support and the modders for their hard work in making Bannerlord an even more enjoyable game!

If you have any questions or feedback about these announcements, feel free to reach out to us on the official Bannerlord Modding Discord server. We would be happy to hear from you and answer any questions you may have.

Thank you for reading, and happy modding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment