Changes

Jump to navigation Jump to search
m
Replace deprecated <source> tags with <syntaxhighlight> tags; add new template Template:Modder compatibility header
Line 1: Line 1:  
←[[Modding:Index|Index]]
 
←[[Modding:Index|Index]]
   −
'''This page is for modders. Players: see [[Modding:Mod compatibility]] instead.''' For updating Content Patcher or XNB mods, see [[Modding:Migrate XNB changes to Stardew Valley 1.3|''Migrate XNB changes to Stardew Valley 1.3'']].
+
{{Modder compatibility header}}
 +
For updating Content Patcher or XNB mods, see [[Modding:Migrate XNB changes to Stardew Valley 1.3|''Migrate XNB changes to Stardew Valley 1.3'']].
    
This page explains how to update your SMAPI mod code for compatibility with Stardew Valley 1.3.
 
This page explains how to update your SMAPI mod code for compatibility with Stardew Valley 1.3.
Line 31: Line 32:  
===⚠ Net fields===
 
===⚠ Net fields===
 
A 'net type' is any of several new classes which Stardew Valley 1.3 uses to sync data between players, named for the <code>Net</code> prefix in their name. A net type can represent a simple value like <tt>NetBool</tt>, or complex values like <tt>NetFieldDictionary</tt>. Many existing fields have been converted to net types (called 'net fields'), each wrapping the underlying value:
 
A 'net type' is any of several new classes which Stardew Valley 1.3 uses to sync data between players, named for the <code>Net</code> prefix in their name. A net type can represent a simple value like <tt>NetBool</tt>, or complex values like <tt>NetFieldDictionary</tt>. Many existing fields have been converted to net types (called 'net fields'), each wrapping the underlying value:
: <source lang="C#">
+
: <syntaxhighlight lang="C#">
 
NetString str = new NetString("bar");
 
NetString str = new NetString("bar");
 
if (str.Value == "bar") // true
 
if (str.Value == "bar") // true
</source>
+
</syntaxhighlight>
    
Impact on mods:
 
Impact on mods:
Line 166: Line 167:  
<ul>
 
<ul>
 
<li>For a reference type (i.e. one that can contain <tt>null</tt>), you can use the <tt>.Value</tt> property (or <tt>.FieldDict</tt> for a <tt>NetDictionary</tt>):
 
<li>For a reference type (i.e. one that can contain <tt>null</tt>), you can use the <tt>.Value</tt> property (or <tt>.FieldDict</tt> for a <tt>NetDictionary</tt>):
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
if (building.indoors.Value == null)
 
if (building.indoors.Value == null)
</source>
+
</syntaxhighlight>
    
Or convert the value before comparison:
 
Or convert the value before comparison:
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
GameLocation indoors = building.indoors.Value;
 
GameLocation indoors = building.indoors.Value;
 
if(indoors == null)
 
if(indoors == null)
 
   // ...
 
   // ...
</source></li>
+
</syntaxhighlight></li>
 
<li>For a value type (i.e. one that can't contain <tt>null</tt>), check if the parent is null (if needed) and compare with <tt>.Value</tt>:
 
<li>For a value type (i.e. one that can't contain <tt>null</tt>), check if the parent is null (if needed) and compare with <tt>.Value</tt>:
<source lang="c#">
+
<syntaxhighlight lang="c#">
 
if (item != null && item.category.Value == 0)
 
if (item != null && item.category.Value == 0)
</source></li>
+
</syntaxhighlight></li>
 
</ul>
 
</ul>
  
114

edits

Navigation menu