Writing Code
You should have a project that looks like this:
- .gitignore
- CHANGELOG.md
- Directory.Build.targets
- icon.png
- LICENSE
- README.md
- ResoniteMod.sln
- thunderstore.toml
Directory.config/
- dotnet-tools.json
Directorysrc/
DirectoryResoniteMod/
- Plugin.cs
- ResoniteMod.csproj
Open the project in your IDE of choice where the .sln
file is, and then open the Plugin.cs
file. It should look something like this:
using BepInEx;using BepInEx.Logging;using BepInEx.NET.Common;using BepInExResoniteShim;
namespace ResoniteMod;
[ResonitePlugin(PluginMetadata.GUID, PluginMetadata.NAME, PluginMetadata.VERSION, PluginMetadata.AUTHORS, PluginMetadata.REPOSITORY_URL)][BepInDependency(BepInExResoniteShim.PluginMetadata.GUID, BepInDependency.DependencyFlags.HardDependency)]public class Plugin : BasePlugin{ internal static new ManualLogSource? Log;
public override void Load() { // Plugin startup logic Log = base.Log; Log.LogInfo($"Plugin {PluginMetadata.GUID} is loaded!"); }}
This is a very basic BepInEx 6 plugin.
Work in progress documentation, more will be added. For now, for more info, see BepInEx’s own documentation:
Creating a new plugin project—Plugin structure
You can also follow the links to learn more about each thing mentioned:
Logging: lethal.wiki
Custom Configs: lethal.wiki
Patching Code: lethal.wiki
For patching/hooking methods, you can use MonoMod or HarmonyX. See lethal.wiki for more in-depth introductions on using them.
All of these libraries are compatible with each other as HarmonyX and MonoDetour simply use MonoMod.RuntimeDetour under the hood.
Writing Your First Patch
Section titled “Writing Your First Patch”work in progress.