Modding:Migrate to Stardew Valley 1.3

From Stardew Valley Wiki
Revision as of 18:43, 10 April 2018 by Pathoschild (talk | contribs) (→‎SMAPI mods: expand)
Jump to navigation Jump to search
Axe.png
Article Stub

This article is a stub and is missing information. You can help Stardew Valley Wiki by expanding it!

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.

SMAPI mods

Overview

At a high level, you can update a mod for Stardew Valley 1.3 single player like this:

  1. Update to Pathoschild.Stardew.ModBuildConfig 2.1. This includes code analysis which will report common problems in Stardew Valley 1.3 as compiler warnings.
  2. Rebuild your solution.
  3. Fix any compiler errors and warnings you see in the Error List pane in Visual Studio (or equivalent for other editors).
  4. See below for specific changes which may affect your mod.
  5. Test all mod features to make sure they work.

Updating for multiplayer will depend on how your mod works. Consider using SMAPI's Context.IsSinglePlayer and Context.IsMainPlayer flags in your logic to avoid conflicts.

If you need help updating your code, feel free to ask questions on the Stardew Valley Discord.

Net types

Stardew Valley 1.3 uses net types (like NetBool and NetInt) to handle multiplayer sync. These types can implicitly convert to their equivalent normal values (like bool x = new NetBool()), but their conversion rules are unintuitive and error-prone. For example, item?.category == null && item?.category != null can both be true at once, and building.indoors != null will be true for a null value in some cases. With the mod build config package installed, rebuild the project and look for warnings in the Error List pane like this:

'{{expression}}' is a {{net type}} field; consider using the {{property name}} property instead. See https://smapi.io/buildmsg/smapi002 for details.

This implicitly converts '{{expression}}' from {{net type}} to {{other type}}, but {{net type}} has unintuitive implicit conversion rules. Consider comparing against the actual value instead to avoid bugs. See https://smapi.io/buildmsg/smapi001 for details.

Suggested fix:

  • Some net fields have an equivalent non-net property, like monster.Health (int) instead of monster.health (NetBool). The mod build package will add a SMAPI002 warning which says which property to use 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;
    if(indoors == null)
       // ...
    
  • For a value type (i.e. one that can't contain null), check if the object is null (if applicable) and compare with .Value:
    if (item != null && item.category.Value == 0)
    

Game1.player.friendships

This field is always null in Stardew Valley 1.3. Use the new Game1.player.friendshipData field instead, which wraps the raw data with a model.

Texture constructor arguments

Many constructors which previously accepted Texture2D texture arguments now take a string textureName 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).

XNB mods and Content Patcher

XNB mods deprecated

XNB mods are no longer recommended. Consider using Content Patcher instead.

Impact in 1.3

Here are the XNB changes in Stardew Valley 1.3.

Notes:

  • I ignored changes to non-English files for simplicity.
  • New content files aren't listed, since they won't impact existing mods and to avoid spoiling some surprises.
  • XNB mods are disproportionately affected, since they replace the entire file. Content Patcher packs are typically unaffected unless they replace the entire file (in which case see the XNB mod column).
  • I don't know what changed in affected map files (if anything), only that the files are different.

Shorthand:

  • 'broken' means removing new content or potentially important changes, or potentially causing significant display bugs. This is a broad category — the game may work fine without it or crash, depending how it uses that specific content.
  • 'mostly unaffected' means mods will only be affected if they edit specific entries or fields.
  • Blank means zero expected impact.
content file changes XNB Content Patcher
Characters/Dialogue/Abigail new content ✘ broken
Characters/Dialogue/Alex new content ✘ broken
Characters/Dialogue/Abigail new content ✘ broken
Characters/Dialogue/Clint new content ✘ broken
Characters/Dialogue/Demetrius new content ✘ broken
Characters/Dialogue/Elliott new content ✘ broken
Characters/Dialogue/Emily new content ✘ broken
Characters/Dialogue/Evelyn new content ✘ broken
Characters/Dialogue/George new content ✘ broken
Characters/Dialogue/Gus new content ✘ broken
Characters/Dialogue/Haley new content ✘ broken
Characters/Dialogue/Harvey new content ✘ broken
Characters/Dialogue/Krobus small text change ✘ minor issues ✓ mostly unaffected
Characters/Dialogue/Leah new content ✘ broken
Characters/Dialogue/Lewis new content ✘ broken
Characters/Dialogue/Linus new content ✘ broken
Characters/Dialogue/`
`MarriageDialogueSebastian
small text change ✘ minor issues ✓ mostly unaffected
Characters/Dialogue/Maru new content ✘ broken
Characters/Dialogue/Pam new content ✘ broken
Characters/Dialogue/Penny new content ✘ broken
Characters/Dialogue/Pierre new content + small text change ✘ broken ✓ mostly unaffected
Characters/Dialogue/Robin new content ✘ broken
Characters/Dialogue/Sam new content ✘ broken
Characters/Dialogue/Sebastian new content ✘ broken
Characters/Dialogue/Shane new content ✘ broken
Characters/Farmer/hats new sprites at bottom ✘ broken ✘ impacts new-hat packs
Characters/Governor new sprites at bottom ✘ broken ✓ mostly unaffected
Characters/Pam new sprites at bottom ✘ broken ✓ mostly unaffected
Characters/Penny new sprites in empty slot ✘ broken ✓ mostly unaffected
Characters/schedules/Abigail format change ✘ broken ✘ broken
Characters/schedules/Alex format change ✘ broken ✘ broken
Characters/schedules/Caroline format change ✘ broken ✘ broken
Characters/schedules/Clint format change ✘ broken ✘ broken
Characters/schedules/Demetrius format change ✘ broken ✘ broken
Characters/schedules/Elliott format change ✘ broken ✘ broken
Characters/schedules/Emily format change ✘ broken ✘ broken
Characters/schedules/Evelyn format change ✘ broken ✘ broken
Characters/schedules/George format change ✘ broken ✘ broken
Characters/schedules/Gus format change ✘ broken ✘ broken
Characters/schedules/Haley format change ✘ broken ✘ broken
Characters/schedules/Harvey format change ✘ broken ✘ broken
Characters/schedules/Jas format change ✘ broken ✘ broken
Characters/schedules/Jodi format change ✘ broken ✘ broken
Characters/schedules/Leah format change ✘ broken ✘ broken
Characters/schedules/Lewis format change ✘ broken ✘ broken
Characters/schedules/Linus format change ✘ broken ✘ broken
Characters/schedules/Marnie format change ✘ broken ✘ broken
Characters/schedules/Maru format change ✘ broken ✘ broken
Characters/schedules/Penny format change ✘ broken ✘ broken
Characters/schedules/Pierre format change ✘ broken ✘ broken
Characters/schedules/Robin format change ✘ broken ✘ broken
Characters/schedules/Sam format change ✘ broken ✘ broken
Characters/schedules/Sebastian format change ✘ broken ✘ broken
Characters/schedules/Shane format change ✘ broken ✘ broken
Characters/schedules/Vincent format change ✘ broken ✘ broken
Characters/schedules/Willy format change ✘ broken ✘ broken
Data/BigCraftablesInformation new content ✘ broken
Data/Blueprints new content + changes ✘ broken ✓ mostly unaffected
Data/CraftingRecipies new content ✘ broken
Data/Crops new content ✘ broken
Data/Events/ArchaeologyHouse minor change ✘ broken ✓ mostly unaffected
Data/Events/Beach new content + changes ✘ broken ✓ mostly unaffected
Data/Events/BusStop new content ✘ broken
Data/Events/Farm new content + changes ✘ broken ✓ mostly unaffected
Data/Events/FarmHouse changes ✘ broken ✓ mostly unaffected
Data/Events/Forest new content ✘ broken
Data/Events/HaleyHouse new content ✘ broken
Data/Events/Mountain new content + changes ✘ broken ✓ mostly unaffected
Data/Events/Saloon new content ✘ broken
Data/Events/SeedShop changes ✘ broken ✓ mostly unaffected
Data/Events/Town new content + changes ✘ broken ✓ mostly unaffected
Data/Events/WizardHouse changes ✘ broken ✓ mostly unaffected
Data/Events/Woods new content ✘ broken
Data/ExtraDialogue new content ✘ broken
Data/Festivals/fall27 changes ✘ broken ✓ mostly unaffected
Data/Festivals/spring13 changes ✘ broken ✓ mostly unaffected
Data/Festivals/spring24 changes ✘ broken ✓ mostly unaffected
Data/Festivals/summer11 new content + changes ✘ broken ✓ mostly unaffected
Data/Festivals/summer28 changes ✘ broken ✓ mostly unaffected
Data/Festivals/winter8 changes ✘ broken ✓ mostly unaffected
Data/Fish new content ✘ broken
Data/Furniture new content ✘ broken
Data/Monsters new content ✘ broken
Data/NPCGiftTastes changes ✘ broken ✓ mostly unaffected
Data/ObjectInformation new content ✘ broken
Data/Quests new content + changes ✘ broken ✓ mostly unaffected
Data/animationDescriptions changes ✘ broken ✓ mostly unaffected
Data/hats new content ✘ broken
Data/mail new content ✘ broken
LooseSprites/ControllerMaps cosmetic changes ✘ minor issues ✘ minor issues
LooseSprites/Cursors new content + changes ✘ broken ✓ mostly unaffected
LooseSprites/chatBox significantly changed ✘ broken ✘ broken
LooseSprites/letterBG new content ✘ broken
LooseSprites/map cosmetic changes ✘ minor issues
Maps/Farm unknown changes ✘ broken? ✘ broken?
Maps/FarmHouse unknown changes ✘ broken? ✘ broken?
Maps/FarmHouse1 unknown changes ✘ broken? ✘ broken?
Maps/FarmHouse1_marriage unknown changes ✘ broken? ✘ broken?
Maps/FarmHouse2 unknown changes ✘ broken? ✘ broken?
Maps/FarmHouse2_marriage unknown changes ✘ broken? ✘ broken?
Maps/Farm_Combat unknown changes ✘ broken? ✘ broken?
Maps/Farm_Fishing unknown changes ✘ broken? ✘ broken?
Maps/Farm_Foraging unknown changes ✘ broken? ✘ broken?
Maps/Farm_Mining unknown changes ✘ broken? ✘ broken?
Maps/Railroad unknown changes ✘ broken? ✘ broken?
Maps/Sewer unknown changes ✘ broken? ✘ broken?
Maps/sewerTiles new content ✘ broken ✓ mostly unaffected
Maps/Town unknown changes ✘ broken? ✘ broken?
Maps/fall_town new content ✘ broken ✓ mostly unaffected
Maps/paths new content ✘ minor issues
Maps/spring_town new content ✘ broken ✓ mostly unaffected
Maps/springobjects new content + cosmetic changes ✘ broken ✓ mostly unaffected
Maps/summer_town new content ✘ broken ✓ mostly unaffected
Maps/winter_town new content ✘ broken ✓ mostly unaffected
Portraits/MrQi new content ✘ broken
SewerTiles new content ✘ broken ✓ mostly unaffected
Strings/Characters new content ✘ broken
Strings/Events new content ✘ broken
Strings/Locations new content ✘ broken
Strings/Objects new content ✘ broken
Strings/StringsFromCSFiles new content ✘ broken
Strings/UI new content + changes ✘ broken
TileSheets/Craftables new content + significant changes
(replaced sprites in red, edited in orange)
✘ broken ✘ possibly broken
TileSheets/crops new content ✘ broken ✓ mostly unaffected
TileSheets/furniture new content ✘ broken ✓ mostly unaffected
fall_town new content ✘ broken ✓ mostly unaffected
paths new content ✘ minor issues
spring_town new content ✘ broken ✓ mostly unaffected
winter_town new content ✘ broken ✓ mostly unaffected