Changes

Jump to navigation Jump to search
m
Replace deprecated <source> tags with <syntaxhighlight> tags
Line 23: Line 23:  
<ol>
 
<ol>
 
<li>Edit your mod's <tt>.csproj</tt> project file, and add this to the first <tt>&lt;PropertyGroup&gt;</tt> section:
 
<li>Edit your mod's <tt>.csproj</tt> project file, and add this to the first <tt>&lt;PropertyGroup&gt;</tt> section:
<source lang="xml">
+
<syntaxhighlight lang="xml">
 
<EnableHarmony>true</EnableHarmony>
 
<EnableHarmony>true</EnableHarmony>
</source></li>
+
</syntaxhighlight></li>
 
<li>In your mod's <tt>Entry</tt> method, use Harmony's code API to register patches:
 
<li>In your mod's <tt>Entry</tt> method, use Harmony's code API to register patches:
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);
 
var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID);
   Line 35: Line 35:  
   prefix: new HarmonyMethod(typeof(ObjectPatches), nameof(ObjectPatches.CanBePlacedHere_Prefix))
 
   prefix: new HarmonyMethod(typeof(ObjectPatches), nameof(ObjectPatches.CanBePlacedHere_Prefix))
 
);
 
);
</source></li>
+
</syntaxhighlight></li>
 
<li>See the {{github|pardeike/Harmony/wiki|Harmony 1.2 wiki}} (not 2.0!) for tutorials and documentation.</li>
 
<li>See the {{github|pardeike/Harmony/wiki|Harmony 1.2 wiki}} (not 2.0!) for tutorials and documentation.</li>
 
</ol>
 
</ol>
Line 43: Line 43:  
<li>See [[#When to use Harmony|when to use Harmony]].</li>
 
<li>See [[#When to use Harmony|when to use Harmony]].</li>
 
<li>Unhandled errors in a patch can be hard to troubleshoot, which often leads to players asking for help on the SMAPI page instead of your mod. '''Please''' handle errors, log them, and default to the original code. For example:
 
<li>Unhandled errors in a patch can be hard to troubleshoot, which often leads to players asking for help on the SMAPI page instead of your mod. '''Please''' handle errors, log them, and default to the original code. For example:
<source lang="C#">
+
<syntaxhighlight lang="C#">
 
public class ObjectPatches
 
public class ObjectPatches
 
{
 
{
Line 68: Line 68:  
     }
 
     }
 
}
 
}
</source>
+
</syntaxhighlight>
 
</li>
 
</li>
 
<li>Use postfixes when possible for best compatibility and stability.</li>
 
<li>Use postfixes when possible for best compatibility and stability.</li>
 
<li>Don't use transpile patches unless you have no choice and you know what you're doing. This has a much higher chance of causing issues, is more fragile and likely to break in game updates, and makes it much less likely that other modders can help if you need it.</li>
 
<li>Don't use transpile patches unless you have no choice and you know what you're doing. This has a much higher chance of causing issues, is more fragile and likely to break in game updates, and makes it much less likely that other modders can help if you need it.</li>
 
</ol>
 
</ol>
114

edits

Navigation menu