Getting Started with Modding using BepInEx
Install
- Installing Nine Chronicles at https://nine-chronicles.com/start
Verifying Nine Chronicles Operation (1st time)
- Launch the Nine Chronicles launcher and player to ensure they are working correctly.
- Close the Nine Chronicles player after confirmation. You may leave the launcher running.
Installing BepInEx 5 LTS
- Download BepInEx 5 LTS version.
- https://github.com/BepInEx/BepInEx/releases/tag/v5.4.22
- BepInEx_x64_5.4.22.0.zip
- Extract the BepInEx zip file into the folder where Nine Chronicles player is installed.
- e.g.,
C:\Users{username}\Roaming\Nine Chronicles\player\main\
- e.g.,
- After extraction, the BepInEx folder contains only the core folder at this point.
Verifying Nine Chronicles Operation (2nd time)
- Check if the Nine Chronicles player operates correctly with the default BepInEx installation.
- Close the Nine Chronicles player after confirmation.
Reviewing and Configuring the Automatically Generated BepInEx Structure
Review the structure inside the extracted BepInEx folder.
Open the BepInEx.cfg file inside the config folder to modify some settings.
[Chainloader]
HideManagerGameObject = true
[Logging.Console]
Enabled = true
[Preloader.Entrypoint]
Type = Camera
Verifying Nine Chronicles Operation (3rd time)
- After modifying the BepInEx settings, confirm that the Nine Chronicles player operates correctly.
- Notice the difference with the BepInEx log terminal opening.
- Close the Nine Chronicles player after confirmation.
Developing Mods
- Create a New dotnet Project
- Target Framework: .NET Standard 2.1
- Lang Version: 9.0
- Add Basic Dependencies
- Location e.g.,
C:\Users{username}\Roaming\Nine Chronicles\player\main\NineChronicles_Data\Managed\
- UnityEngine.CoreModule.dll
- UnityEngine.dll
- Lib9c.dll
- Nekoyume.dll
- Location e.g.,
C:\Users{username}\Roaming\Nine Chronicles\player\main\BepInEx\core\
- 0Harmony.dll
- BepInEx.dll
- Location e.g.,
- Create a Plugin
- To implement an example plugin, add additional dependencies
- You can check example code here [https://github.com/planetarium/NineChronicles.Mods/tree/sample-dotnet-code/Sample]
- Location e.g.,
C:\Users{username}\Roaming\Nine Chronicles\player\main\NineChronicles_Data\Managed\
- UnityEngine.InputLegacyModule.dll
- To implement an example plugin, add additional dependencies
e.g., TestModPlugin.cs
csharp
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
namespace NineChronicles.Mods.TestMod
{
[BepInPlugin(ModGUID, ModName, ModVersion)]
public class TestModPlugin : BaseUnityPlugin
{
private const string ModGUID = "com.ninechronicles.mods.testmod";
private const string ModName = "Test Mod";
private const string ModVersion = "0.1.0";
private static TestModPlugin Instance;
private readonly Harmony _harmony = new Harmony(ModGUID);
internal ManualLogSource _logger;
private void Awake()
{
if (Instance is null)
{
Instance = this;
}
_logger = Logger.CreateLogSource(ModGUID);
_logger.LogInfo($"{ModName} is loaded!");
_harmony.PatchAll(typeof(TestModPlugin));
_harmony.PatchAll(typeof(Patches.NotifyKeyboardInput));
}
}
}
e.g., NotifyKeyboardInput.cs
csharp
using HarmonyLib;
using Nekoyume.Game;
using Nekoyume.UI;
using UnityEngine;
namespace NineChronicles.Mods.TestMod.Patches
{
[HarmonyPatch(typeof(ActionCamera))]
internal class NotifyKeyboardInput
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void PostfixUpdate()
{
if (Input.GetKeyDown(KeyCode.Space))
{
NotificationSystem.Push(
Nekoyume.Model.Mail.MailType.System,
"Space key is pressed!",
Nekoyume.UI.Scroller.NotificationCell.NotificationType.Notification);
}
}
}
}
Applying Mods
- Build the Plugin
- e.g., TestMod.dll
- Copy the mod dll file to the Nine Chronicles player
- e.g.,
C:\Users{username}\Roaming\Nine Chronicles\player\main\BepInEx\plugins\
- e.g.,
Verifying Mod Operation
- After applying the mod dll file, check if the Nine Chronicles player operates normally.
- Confirm the mod is loaded properly in the BepInEx log terminal.
- Loading [Test Mod 0.1.0]
- Test Mod is loaded!
- Verify the mod operates as expected.
- e.g., Pressing the space key triggers the 9c-unity NotificationSystem.Push() function.
- Close the Nine Chronicles player after confirmation.