Modding:Modder Guide/Test and Troubleshoot
- Get started
- Game fundamentals
- Test & troubleshoot
- Release
- API reference
- Basic SMAPI APIs:
- Advanced SMAPI APIs:
- Specific guides
This page helps solve common issues when creating mods. For issues using mods, see Modding:Player Guide/Troubleshooting.
Fix common build 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:
Mismatch between the processor architecture...
Sample warning: "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."
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 change your platform target to x86.
This implicitly converts...
Sample warning: "This implicitly converts '{0}' from Net{1} to {2}, but Net{1} has unintuitive implicit conversion rules. Consider comparing against the actual value instead to avoid bugs. See https://smapi.io/buildmsg/avoid-implicit-net-field-cast for details."
Your code is referencing a net field, which can cause subtle bugs. The field you're referencing has an equivalent non-net property, like monster.Health (int) instead of monster.health (NetBool). Change your code to use the suggested property instead.
FieldName is a Net* field...
Sample warning: "'{0}' is a Net{1} field; consider using the {2} property instead. See https://smapi.io/buildmsg/avoid-net-field for details."
Your code is referencing a net field, which can cause subtle bugs. You should access the underlying value instead:
- For a reference type (i.e. one that can contain null), you can use the .Value property (or .FieldDict for a NetDictionary):
if (building.indoors.Value == null)
Or convert the value before comparison:
GameLocation indoors = building.indoors.Value; if(indoors == null) // ...
- For a value type (i.e. one that can't contain null), check if the parent is null (if needed) and compare with .Value:
if (item != null && item.category.Value == 0)
The FieldName field is obsolete...
Sample warning: "The 'Character.friendships' field is obsolete and should be replaced with 'friendshipData'. See https://smapi.io/buildmsg/avoid-obsolete-field for details."
You're referencing a field which should no longer be used. Use the suggested field name instead to fix it.
Ask for help
If you still need help, ask for help in #modding on the Stardew Valley Discord. The Stardew Valley modding community is very welcoming!