Modding:Modder Guide/Game Fundamentals
< Modding:Modder Guide
Jump to navigation
Jump to search
Revision as of 23:31, 1 June 2018 by Pathoschild (talk | contribs) (+ net fields from Modding:Migrate to Stardew Valley 1.3 (only author is Pathoschild))
This page explains some of the Stardew Valley fundamentals that are useful for modders. See also Modding:Common tasks.
Data structures
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 Net
prefix in their name. A net type can represent a simple value like NetBool, or complex values like NetFieldDictionary. Many existing fields have been converted to net types (called 'net fields'), each wrapping the underlying value:
NetString str = new NetString("bar"); if (str.Value == "bar") // true
Impact on mods:
- The game will regularly collect all the net fields reachable from Game1.netWorldState and sync them with other players. That means that many mod changes will be synchronised automatically in multiplayer.
- Net fields can implicitly convert to their equivalent normal values (like
bool x = new NetBool(true)
), but their conversion rules can be counterintuitive and error-prone. For example,item?.category == null && item?.category != null
can both be true at once. Always avoid implicit casts to minimise bugs.
Suggested fix:
- With the latest mod build package installed, rebuild your project. The package will detect net field references you need to update, and show an appropriate warning. See fix common build warnings below.