Difference between revisions of "Modding:Migrate to Harmony 2.0"

From Stardew Valley Wiki
Jump to navigation Jump to search
(+ TOC)
(+ release notes, reorganize a bit, minor changes)
Line 5: Line 5:
 
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.'''
 
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.'''
  
This page explains how to update your mods for compatibility with Harmony 2.0.0. This only applies to mods which use Harmony directly; [[Modding:Modder Guide/APIs/Harmony|this is discouraged]] in most cases, isn't officially part of SMAPI's public API, and isn't subject to SMAPI's normal versioning policy.
+
This page explains how to update your mods for compatibility with Harmony 2.0. This only applies to mods which use Harmony directly; [[Modding:Modder Guide/APIs/Harmony|this is discouraged]] in most cases, isn't officially part of SMAPI's public API, and isn't subject to SMAPI's normal versioning policy.
  
 
__TOC__
 
__TOC__
  
==Before you start==
+
==What's new?==
Make sure you follow best practices outlined in the [[Modding:Modder Guide/APIs/Harmony|Harmony guide]]. In particular, use the <code>EnableHarmony</code> option (don't reference the Harmony DLL directly) and use the code API.
+
See the [https://github.com/pardeike/Harmony/releases/tag/v2.0.0 Harmony 2.0 release notes] and [https://harmony.pardeike.net Harmony 2.0 documentation] for more info.
  
==Basic changes==
+
==Migration steps==
 +
# Make sure you follow best practices outlined in the [[Modding:Modder Guide/APIs/Harmony|Harmony guide]]. In particular, use the <code>EnableHarmony</code> option (don't reference the Harmony DLL directly) and use the code API.
 
# Change <code>using Harmony;</code> to <code>using HarmonyLib;</code>.
 
# Change <code>using Harmony;</code> to <code>using HarmonyLib;</code>.
 
# Change <code>HarmonyInstance harmony = HarmonyInstance.Create("your mod id");</code> to <code>Harmony harmony = new Harmony("your mod id");</code>.
 
# Change <code>HarmonyInstance harmony = HarmonyInstance.Create("your mod id");</code> to <code>Harmony harmony = new Harmony("your mod id");</code>.
 
# Recompile the mod.
 
# Recompile the mod.
  
That's it! Otherwise usage should be identical. Harmony 2.0.0 adds a number of new features; see the [https://harmony.pardeike.net official documentation] for more info.
+
That's it! Otherwise usage should be identical.
  
 
[[Category:Modding]]
 
[[Category:Modding]]

Revision as of 16:51, 16 February 2020

Index

The following describes the upcoming SMAPI 3.x, and may change before release.

This page is for modders. Players: see Modding:Mod compatibility instead.

This page explains how to update your mods for compatibility with Harmony 2.0. This only applies to mods which use Harmony directly; this is discouraged in most cases, isn't officially part of SMAPI's public API, and isn't subject to SMAPI's normal versioning policy.

What's new?

See the Harmony 2.0 release notes and Harmony 2.0 documentation for more info.

Migration steps

  1. Make sure you follow best practices outlined in the Harmony guide. In particular, use the EnableHarmony option (don't reference the Harmony DLL directly) and use the code API.
  2. Change using Harmony; to using HarmonyLib;.
  3. Change HarmonyInstance harmony = HarmonyInstance.Create("your mod id"); to Harmony harmony = new Harmony("your mod id");.
  4. Recompile the mod.

That's it! Otherwise usage should be identical.