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

From Stardew Valley Wiki
Jump to navigation Jump to search
m (Pathoschild moved page User:Pathoschild/Modding:Migrate to Harmony 2.0 to Modding:Migrate to Harmony 2.0 without leaving a redirect: Prepare for Harmony 2.0 release)
(+ TOC)
Line 6: Line 6:
  
 
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.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__
  
 
==Before you start==
 
==Before you start==

Revision as of 18:35, 8 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.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.

Before you start

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.

Basic changes

  1. Change using Harmony; to using HarmonyLib;.
  2. Change HarmonyInstance harmony = HarmonyInstance.Create("your mod id"); to Harmony harmony = new Harmony("your mod id");.
  3. Recompile the mod.

That's it! Otherwise usage should be identical. Harmony 2.0.0 adds a number of new features; see the official documentation for more info.