Changes

Jump to navigation Jump to search
polish, copyedit, expand
Line 1: Line 1: −
{{stub}}
+
←[[Modding:Index|Index]]
    
'''This page is for modders. Players: see [[Modding:SMAPI compatibility]] instead.'''
 
'''This page is for modders. Players: see [[Modding:SMAPI compatibility]] instead.'''
   −
This page explains the most common changes needed in mods for compatibility with Stardew Valley 1.3.
+
This page explains how to update your mod code for compatibility with Stardew Valley 1.3.
    
==SMAPI mods==
 
==SMAPI mods==
 
===Overview===
 
===Overview===
At a high level, you can update a mod for Stardew Valley 1.3 '''single player''' like this:
+
At a high level, here's how to update a SMAPI mod:
# Update to [https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig Pathoschild.Stardew.ModBuildConfig 2.1]. This includes code analysis which will report common problems in Stardew Valley 1.3 as compiler warnings.
+
# Update the [https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig mod build NuGet package] to 2.1-beta. (You may need to enable the 'include prerelease' checkbox to see the beta.)<br />''This adds support for Stardew Valley 1.3, and adds code analysis which will report common problems in Stardew Valley 1.3 as compiler warnings.''
 
# Rebuild your solution.
 
# Rebuild your solution.
 
# Fix any compiler errors and warnings you see in the ''Error List'' pane in Visual Studio (or equivalent for other editors).
 
# Fix any compiler errors and warnings you see in the ''Error List'' pane in Visual Studio (or equivalent for other editors).
# See below for specific changes which may affect your mod.
+
# See below for help with specific changes and warnings.
 
# Test all mod features to make sure they work.
 
# Test all mod features to make sure they work.
   −
Updating for multiplayer will depend on how your mod works. Consider using SMAPI's <tt>Context.IsSinglePlayer</tt> and <tt>Context.IsMainPlayer</tt> flags in your logic to avoid conflicts.
+
The game will automatically synchronise most world changes to other players, but you might need further changes to work in multiplayer mode. Questions to consider: will your mod cause any problems if two players both have it installed? What if they have different configuration? Maybe it should only work for the main player? You can use [[Modding:SMAPI APIs#Context|SMAPI's <tt>Context.IsSinglePlayer</tt> and <tt>Context.IsMainPlayer</tt> flags]] in your logic to avoid conflicts.
    
If you need help updating your code, feel free to ask questions [[Modding:Community#Discord|on the Stardew Valley Discord]].
 
If you need help updating your code, feel free to ask questions [[Modding:Community#Discord|on the Stardew Valley Discord]].
Line 47: Line 47:     
===Texture constructor arguments===
 
===Texture constructor arguments===
Many constructors which previously accepted <tt>Texture2D texture</tt> arguments now take a <tt>string textureName</tt> argument instead. It's usually better to use SMAPI's content API to override textures, though you can change the cached texture after the object is constructed (requires reflection in some cases).
+
Many constructors which previously accepted <tt>Texture2D texture</tt> arguments now take a <tt>string textureName</tt> argument instead. It's usually better to use SMAPI's content API to override textures instead. You can change the cached texture after the object is constructed (may need [[Modding:SMAPI APIs#Reflection|reflection]]), but don't change the texture name to avoid multiplayer sync issues.
 +
 
 +
===Common compiler warnings===
 +
Make sure you check your Error List pane in Visual Studio (or equivalent in other IDEs) and fix any warnings. Here are some common ones:
 +
 
 +
* "''There was a mismatch between the processor architecture of the project being built "{0}" and the processor architecture of the reference "{1}". This mismatch may cause runtime failures.''"<br />That warning is normal. The error is saying that your build is set to 'Any CPU', but Stardew Valley is x86-only so it'll only work in x86 anyway. You can either ignore it, or [https://msdn.microsoft.com/en-us/library/ms185328.aspx change your platform target] to x86.
 +
 
 +
* "''This implicitly converts '{0}' from {1} to {2}, but {1} has unintuitive implicit conversion rules. Consider comparing against the actual value instead to avoid bugs. See https://smapi.io/buildmsg/smapi001 for details.''"<br />See [[#Net types]].
 +
 
 +
* "'''{0}' is a {1} field; consider using the {2} property instead. See https://smapi.io/buildmsg/smapi002 for details.''"<br />See [[#Net types]].
 +
 
 +
* "''The '{0}' field is obsolete and should be replaced with '{1}'. See https://smapi.io/buildmsg/smapi003 for details.''"<br />You're referencing a field which should no longer be used. Just use the suggested field name instead to fix it.
    
==XNB mods and Content Patcher==
 
==XNB mods and Content Patcher==
translators
8,403

edits

Navigation menu