Difference between revisions of "Modding:Migrate to SMAPI 3.0"
Pathoschild (talk | contribs) (→What's changing?: fix inconsistent grammar) |
Pathoschild (talk | contribs) (→Is this the modapocalypse?: copyedit) |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
←[[Modding:Index|Index]] | ←[[Modding:Index|Index]] | ||
− | + | {{Modder compatibility header}} | |
− | + | This page explains how to update your mod code for compatibility with SMAPI 3.0. See also [[Modding:Migrate to Stardew Valley 1.4]]. | |
− | This page explains how to update your mod code for compatibility with SMAPI 3.0 | ||
==Overview== | ==Overview== | ||
Line 9: | Line 8: | ||
[[File:SMAPI compatibility.png|thumb|SMAPI compatibility over time. The SMAPI 2.0 release in October 2017 appears as a small bump. The Stardew Valley 1.3 release in May 2018 appears as a sudden cliff.]] | [[File:SMAPI compatibility.png|thumb|SMAPI compatibility over time. The SMAPI 2.0 release in October 2017 appears as a small bump. The Stardew Valley 1.3 release in May 2018 appears as a sudden cliff.]] | ||
− | Events are arguably the most important and most visible part of SMAPI, but they've stayed essentially unchanged since SMAPI 0.40. New events have been added organically since then, but the event system has always been separate from the rest of SMAPI — they're inconsistent, have some weird behaviours (like < | + | Events are arguably the most important and most visible part of SMAPI, but they've stayed essentially unchanged since SMAPI 0.40. New events have been added organically since then, but the event system has always been separate from the rest of SMAPI — they're inconsistent, have some weird behaviours (like <samp>MenuEvents.MenuChanged</samp> not being raised when a menu is closed), aren't available through the same helper as every other API, and there are some glaring omissions in the available events. |
SMAPI 3.0 is the release that fixes all that. This release... | SMAPI 3.0 is the release that fixes all that. This release... | ||
Line 19: | Line 18: | ||
* Events now have relevant event arguments. | * Events now have relevant event arguments. | ||
* Each mod now has its own event instances, to support features like mod message targeting. | * Each mod now has its own event instances, to support features like mod message targeting. | ||
+ | |||
+ | SMAPI 3.0 also adds compatibility with Stardew Valley 1.4, drops all deprecated APIs, and makes a number of other changes listed below. | ||
===Is this the modapocalypse?=== | ===Is this the modapocalypse?=== | ||
− | Nope. Although this is a major change, significant | + | Nope. Although this is a major change, significant efforts were undertaken to minimize the impact: |
− | * the old events | + | * the old events were supported for a long time with increasingly prominent warnings in the SMAPI console about their deprecation and removal; |
− | * pull requests | + | * pull requests were submitted to update affected open-source mods; |
− | * unofficial updates | + | * unofficial updates were created for mods which haven't updated officially by the time SMAPI 3.0 is released; |
− | * the changes | + | * the changes were actively communicated and documented to modders. |
In addition, the current target is ''at least'' 95% compatibility for open-source mods before SMAPI 3.0 is released. All of this means that the 3.0 release should have minimal impact on mod compatibility, despite the scope of the changes. | In addition, the current target is ''at least'' 95% compatibility for open-source mods before SMAPI 3.0 is released. All of this means that the 3.0 release should have minimal impact on mod compatibility, despite the scope of the changes. | ||
Line 37: | Line 38: | ||
==Changes== | ==Changes== | ||
+ | ===Mod build package updated=== | ||
+ | Update the [https://www.nuget.org/packages/Pathoschild.Stardew.ModBuildConfig mod build package] for compatibility with SMAPI 3.0. | ||
+ | |||
+ | ===Mods are loaded earlier=== | ||
+ | Mods were previously loaded right before the first <samp>UpdateTicking</samp> event, which is too late for some changes like intercepting core assets. SMAPI 3.0 loads them much earlier, before the game is fully initialised. '''Do not depend on game fields like <samp>Game1.objectInformation</samp> having a valid value in your <samp>Entry</samp> method!''' You can use the <samp>GameLaunched</samp> event for that instead. See [[Modding:Modder Guide/APIs/Mod structure#Mod entry]] for more info. | ||
+ | |||
+ | For example, let's say you have code like this: | ||
+ | <syntaxhighlight lang="c#"> | ||
+ | public override void Entry(IModHelper helper) | ||
+ | { | ||
+ | this.Config = helper.ReadConfig<ModConfig>(); | ||
+ | |||
+ | CommunityCenter communityCenter = (CommunityCenter)Game1.getLocationFromName("CommunityCenter"); | ||
+ | this.VaultRoomID = communityCenter.getAreaNumberFromName("Vault"); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | That code fails in SMAPI 3.0, because no locations are loaded yet. This code could be rewritten like this: | ||
+ | <syntaxhighlight lang="c#"> | ||
+ | public override void Entry(IModHelper helper) | ||
+ | { | ||
+ | this.Config = helper.ReadConfig<ModConfig>(); | ||
+ | |||
+ | helper.Events.GameLoop.GameLaunched += this.OnGameLaunched; | ||
+ | } | ||
+ | |||
+ | private void OnGameLaunched(object sender, GameLaunchedEventArgs args) | ||
+ | { | ||
+ | CommunityCenter communityCenter = (CommunityCenter)Game1.getLocationFromName("CommunityCenter"); | ||
+ | this.VaultRoomID = communityCenter.getAreaNumberFromName("Vault"); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
===API changes=== | ===API changes=== | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 45: | Line 79: | ||
! conversion notes | ! conversion notes | ||
|- | |- | ||
− | | < | + | | <samp>helper.GetContentPacks</samp> |
| → | | → | ||
− | | < | + | | <samp>helper.ContentPacks.GetOwned</samp> |
| Identical usage. | | Identical usage. | ||
|- | |- | ||
− | | < | + | | <samp>helper.CreateTransitionalContentPack</samp> |
| → | | → | ||
− | | < | + | | <samp>helper.ContentPacks.CreateTemporary</samp> |
| Identical usage. (This was a temporary method for the transition to [[Modding:Content packs|SMAPI content packs]], but a few mods have permanent use cases for it.) | | Identical usage. (This was a temporary method for the transition to [[Modding:Content packs|SMAPI content packs]], but a few mods have permanent use cases for it.) | ||
|- | |- | ||
− | | < | + | | <samp>assetData.AsDictionary<T, T>().Set</samp> |
| → | | → | ||
− | | < | + | | <samp>assetData.AsDictionary<T, T>().Data</samp> |
− | | The < | + | | The <samp>Set</samp> methods caused a lot of confusion and were of limited usefulness. You can access the dictionary directly using the <samp>Data</samp> field instead. |
|- | |- | ||
− | | < | + | | <samp>SemanticVersion.Build</samp> |
| → | | → | ||
− | | < | + | | <samp>SemanticVersion.PrereleaseTag</samp> |
| Identical usage. | | Identical usage. | ||
|} | |} | ||
===Event changes=== | ===Event changes=== | ||
− | The former events | + | The former events are removed in SMAPI 3.0. Here's how to convert them to the new events under <samp>this.Helper.Events</samp>. This list only shows equivalent events in SMAPI 3.0; see [[Modding:Modder Guide/APIs/Events|''events'' in the modder guide]] for a full list. |
{| class="wikitable" | {| class="wikitable" | ||
Line 84: | Line 118: | ||
|new events = Input.ButtonPressed, Input.ButtonReleased | |new events = Input.ButtonPressed, Input.ButtonReleased | ||
|summary = Mostly equivalent. | |summary = Mostly equivalent. | ||
− | * Remove < | + | * Remove <samp>e.PlayerIndex</samp> (this was always <samp>PlayerIndex.One</samp>). |
− | * Change < | + | * Change <samp>e.ButtonPressed</samp> to <samp>e.Button</samp>, which is now an [[Modding:Modder Guide/APIs/Utilities#Input|<samp>SButton</samp>]] value. |
− | * Remove < | + | * Remove <samp>e.Value</samp> for trigger events. |
}} | }} | ||
{{/event | {{/event | ||
Line 97: | Line 131: | ||
|new events = Input.ButtonPressed, Input.ButtonReleased | |new events = Input.ButtonPressed, Input.ButtonReleased | ||
|summary = Mostly equivalent. | |summary = Mostly equivalent. | ||
− | * Change < | + | * Change <samp>e.KeyPressed</samp> to <samp>e.Button</samp>, which is now an [[Modding:Modder Guide/APIs/Utilities#Input|<samp>SButton</samp>]] value. |
}} | }} | ||
{{/event | {{/event | ||
Line 107: | Line 141: | ||
|old events = GameEvents.EighthUpdateTick, GameEvents.FourthUpdateTick, GameEvents.HalfSecondTick, GameEvents.QuarterSecondTick, GameEvents.SecondUpdateTick | |old events = GameEvents.EighthUpdateTick, GameEvents.FourthUpdateTick, GameEvents.HalfSecondTick, GameEvents.QuarterSecondTick, GameEvents.SecondUpdateTick | ||
|new events = GameLoop.UpdateTicked | |new events = GameLoop.UpdateTicked | ||
− | |summary = Mostly equivalent. You can use <code>e.IsMultipleOf</code> to choose an update rate (< | + | |summary = Mostly equivalent. You can use <code>e.IsMultipleOf</code> to choose an update rate (<samp>SecondUpdateTick</samp> = 2, <samp>FourthUpdateTick</samp> = 4, <samp>EighthUpdateTick</samp> = 8, <samp>QuarterSecondTick</samp> = 15, and <samp>HalfSecondTick</samp> = 30). |
}} | }} | ||
{{/event | {{/event | ||
|old events = GameEvents.FirstUpdateTick | |old events = GameEvents.FirstUpdateTick | ||
|new events = GameLoop.GameLaunched | |new events = GameLoop.GameLaunched | ||
− | |summary = The new event is raised before the first update tick (the old one happened after it). To do something ''after'' the first update tick, use < | + | |summary = The new event is raised before the first update tick (the old one happened after it). To do something ''after'' the first update tick, use <samp>GameEvents.UpdateTicked</samp> with <samp>if (e.Ticks == 1)</samp>. |
}} | }} | ||
{{/event | {{/event | ||
Line 127: | Line 161: | ||
|old events = GraphicsEvents.OnPostRenderEvent | |old events = GraphicsEvents.OnPostRenderEvent | ||
|new events = Display.Rendered | |new events = Display.Rendered | ||
− | |summary = Equivalent, except the new event isn't triggered during certain special cutscenes and minigames (e.g. the [[Sebastian#Six Hearts|board game scene]]). | + | |summary = Equivalent, except the new event isn't triggered during certain special cutscenes and minigames (''e.g.,'' the [[Sebastian#Six Hearts|board game scene]]). |
}} | }} | ||
{{/event | {{/event | ||
Line 163: | Line 197: | ||
|new events = Input.ButtonPressed, Input.ButtonReleased | |new events = Input.ButtonPressed, Input.ButtonReleased | ||
|summary = Mostly equivalent. | |summary = Mostly equivalent. | ||
− | * Change < | + | * Change <samp>e.IsActionButton</samp> to <samp>e.Button.IsActionButton()</samp>. |
− | * Change < | + | * Change <samp>e.IsUseToolButton</samp> to <samp>e.Button.IsUseToolButton()</samp>. |
− | * Change < | + | * Change <samp>e.SuppressButton</samp> to <samp>this.Helper.Input.Suppress(button)</samp>. |
}} | }} | ||
{{/event | {{/event | ||
Line 185: | Line 219: | ||
|old events = MenuEvents.MenuChanged, MenuEvents.MenuClosed | |old events = MenuEvents.MenuChanged, MenuEvents.MenuClosed | ||
|new events = Display.MenuChanged | |new events = Display.MenuChanged | ||
− | |summary = These caused a lot of confusion (e.g. < | + | |summary = These caused a lot of confusion (''e.g.,'' <samp>MenuEvents.MenuClosed</samp> wasn't called when a menu was closed and immediately replaced), so they've been combined into one event which is called when a menu is opened, closed, or replaced. You can check the <samp>e.OldMenu</samp> and <samp>e.NewMenu</samp> event args to know what the change is (''e.g.,'' to match the old <samp>MenuEvents.MenuClosed</samp>, check <code>if (e.NewMenu == null)</code>). |
}} | }} | ||
{{/event | {{/event | ||
|old events = MineEvents.MineLevelChanged | |old events = MineEvents.MineLevelChanged | ||
|new events = Player.Warped | |new events = Player.Warped | ||
− | |summary = Check <code>if (e.NewLocation is MineShaft mine)</code> to detect a mine level change (the new mine level will be <code>mine.mineLevel</code>). Although the new event is still only called for the current player, that may change in a future version; '''make sure to check < | + | |summary = Check <code>if (e.NewLocation is MineShaft mine)</code> to detect a mine level change (the new mine level will be <code>mine.mineLevel</code>). Although the new event is still only called for the current player, that may change in a future version; '''make sure to check <samp>e.IsLocalPlayer</samp> if you only want to handle the current player'''. |
}} | }} | ||
{{/event | {{/event | ||
|old events = MultiplayerEvents.AfterMainBroadcast, MultiplayerEvents.AfterMainSync, MultiplayerEvents.BeforeMainBroadcast, MultiplayerEvents.BeforeMainSync | |old events = MultiplayerEvents.AfterMainBroadcast, MultiplayerEvents.AfterMainSync, MultiplayerEvents.BeforeMainBroadcast, MultiplayerEvents.BeforeMainSync | ||
|new events = none | |new events = none | ||
− | |summary = No known mods use these. If you need them, consider replacing < | + | |summary = No known mods use these. If you need them, consider replacing <samp>Game1.multiplayer</samp> with a delegating subclass. |
}} | }} | ||
{{/event | {{/event | ||
|old events = PlayerEvents.InventoryChanged | |old events = PlayerEvents.InventoryChanged | ||
|new events = Player.InventoryChanged | |new events = Player.InventoryChanged | ||
− | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check < | + | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check <samp>e.IsLocalPlayer</samp> if you only want to handle the current player'''. |
}} | }} | ||
{{/event | {{/event | ||
|old events = PlayerEvents.LeveledUp | |old events = PlayerEvents.LeveledUp | ||
|new events = Player.LevelChanged | |new events = Player.LevelChanged | ||
− | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check < | + | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check <samp>e.IsLocalPlayer</samp> if you only want to handle the current player'''. |
}} | }} | ||
{{/event | {{/event | ||
|old events = PlayerEvents.Warped | |old events = PlayerEvents.Warped | ||
|new events = Player.Warped | |new events = Player.Warped | ||
− | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check < | + | |summary = Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; '''make sure to check <samp>e.IsLocalPlayer</samp> if you only want to handle the current player'''. |
}} | }} | ||
{{/event | {{/event | ||
Line 255: | Line 289: | ||
|old events = TimeEvents.TimeOfDayChanged | |old events = TimeEvents.TimeOfDayChanged | ||
|new events = GameLoop.TimeChanged | |new events = GameLoop.TimeChanged | ||
− | |summary = Mostly equivalent. Change < | + | |summary = Mostly equivalent. Change <samp>e.OldInt</samp> and <samp>e.NewInt</samp> to <samp>e.OldTime</samp> and <samp>e.NewTime</samp> respectively. |
}} | }} | ||
|} | |} | ||
===Manifest version format=== | ===Manifest version format=== | ||
− | The [[Modding:Modder Guide/APIs/Manifest|< | + | The [[Modding:Modder Guide/APIs/Manifest|<samp>manifest.json</samp>]] no longer allows versions in this form: |
− | < | + | <syntaxhighlight lang="js"> |
"Version": { | "Version": { | ||
"MajorVersion": 1, | "MajorVersion": 1, | ||
Line 268: | Line 302: | ||
"Build": "beta" | "Build": "beta" | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
Versions should be written in the standard string form instead: | Versions should be written in the standard string form instead: | ||
− | < | + | <syntaxhighlight lang="js"> |
"Version": "1.0.0-beta" | "Version": "1.0.0-beta" | ||
− | </ | + | </syntaxhighlight> |
+ | |||
+ | ===Version format=== | ||
+ | SMAPI no longer omits <code>.0</code> patch numbers when formatting versions. For example, the console now shows SMAPI 3.0.0 instead of 3.0. That's more [https://semver.org/ standard], improves compatibility with external tools, and reduces player confusion. | ||
+ | |||
+ | This doesn't affect most mod code. You may need to update your code if you use <samp>ISemanticVersion.ToString()</samp> and compare the output to a hardcoded two-part version string. | ||
[[Category:Modding]] | [[Category:Modding]] |
Latest revision as of 05:53, 26 March 2022
This page is for mod authors. Players: see Modding:Mod compatibility instead.
This page explains how to update your mod code for compatibility with SMAPI 3.0. See also Modding:Migrate to Stardew Valley 1.4.
Overview
What's changing?
Events are arguably the most important and most visible part of SMAPI, but they've stayed essentially unchanged since SMAPI 0.40. New events have been added organically since then, but the event system has always been separate from the rest of SMAPI — they're inconsistent, have some weird behaviours (like MenuEvents.MenuChanged not being raised when a menu is closed), aren't available through the same helper as every other API, and there are some glaring omissions in the available events.
SMAPI 3.0 is the release that fixes all that. This release...
- Completely rewrites the event engine to make events more efficient and enable events that weren't possible before.
- Makes events much more consistent: they're now fully compliant with the .NET design guidelines, have predictable and descriptive names, have consistent event handler signatures, and have clear documentation.
- All events are now accessible through
helper.Events
, so they're discoverable like any other SMAPI API. - Weird behaviours and overlapping events have been eliminated.
- Many new events have been added.
- Events now have relevant event arguments.
- Each mod now has its own event instances, to support features like mod message targeting.
SMAPI 3.0 also adds compatibility with Stardew Valley 1.4, drops all deprecated APIs, and makes a number of other changes listed below.
Is this the modapocalypse?
Nope. Although this is a major change, significant efforts were undertaken to minimize the impact:
- the old events were supported for a long time with increasingly prominent warnings in the SMAPI console about their deprecation and removal;
- pull requests were submitted to update affected open-source mods;
- unofficial updates were created for mods which haven't updated officially by the time SMAPI 3.0 is released;
- the changes were actively communicated and documented to modders.
In addition, the current target is at least 95% compatibility for open-source mods before SMAPI 3.0 is released. All of this means that the 3.0 release should have minimal impact on mod compatibility, despite the scope of the changes.
How to update your mod
You don't need to comb through your code manually. SMAPI can tell you if you're using a deprecated interface:
- Use the latest SMAPI for developers download. This will show deprecation messages in the console:
- When you look at the code, you'll see a deprecation warning with a hint of how to fix it:
- You can refer to the following sections on how to replace specific interfaces.
Changes
Mod build package updated
Update the mod build package for compatibility with SMAPI 3.0.
Mods are loaded earlier
Mods were previously loaded right before the first UpdateTicking event, which is too late for some changes like intercepting core assets. SMAPI 3.0 loads them much earlier, before the game is fully initialised. Do not depend on game fields like Game1.objectInformation having a valid value in your Entry method! You can use the GameLaunched event for that instead. See Modding:Modder Guide/APIs/Mod structure#Mod entry for more info.
For example, let's say you have code like this:
public override void Entry(IModHelper helper)
{
this.Config = helper.ReadConfig<ModConfig>();
CommunityCenter communityCenter = (CommunityCenter)Game1.getLocationFromName("CommunityCenter");
this.VaultRoomID = communityCenter.getAreaNumberFromName("Vault");
}
That code fails in SMAPI 3.0, because no locations are loaded yet. This code could be rewritten like this:
public override void Entry(IModHelper helper)
{
this.Config = helper.ReadConfig<ModConfig>();
helper.Events.GameLoop.GameLaunched += this.OnGameLaunched;
}
private void OnGameLaunched(object sender, GameLaunchedEventArgs args)
{
CommunityCenter communityCenter = (CommunityCenter)Game1.getLocationFromName("CommunityCenter");
this.VaultRoomID = communityCenter.getAreaNumberFromName("Vault");
}
API changes
old API | → | new API | conversion notes |
---|---|---|---|
helper.GetContentPacks | → | helper.ContentPacks.GetOwned | Identical usage. |
helper.CreateTransitionalContentPack | → | helper.ContentPacks.CreateTemporary | Identical usage. (This was a temporary method for the transition to SMAPI content packs, but a few mods have permanent use cases for it.) |
assetData.AsDictionary<T, T>().Set | → | assetData.AsDictionary<T, T>().Data | The Set methods caused a lot of confusion and were of limited usefulness. You can access the dictionary directly using the Data field instead. |
SemanticVersion.Build | → | SemanticVersion.PrereleaseTag | Identical usage. |
Event changes
The former events are removed in SMAPI 3.0. Here's how to convert them to the new events under this.Helper.Events. This list only shows equivalent events in SMAPI 3.0; see events in the modder guide for a full list.
old event | → | new event | conversion notes |
---|---|---|---|
#ContentEvents.AfterLocaleChanged | → | none | Mods very rarely need to handle this, since SMAPI's translation and content APIs do. Since the locale can only change on the title screen, mods that used this can check once the save is loaded instead. |
#ControlEvents.ControllerButtonPressed ControlEvents.ControllerButtonReleased ControlEvents.ControllerTriggerPressed ControlEvents.ControllerTriggerReleased |
→ | Input.ButtonPressed Input.ButtonReleased |
Mostly equivalent.
|
#ControlEvents.KeyboardChanged | → | Input.ButtonPressed Input.ButtonReleased |
Not directly equivalent; may need to rewrite affected code. |
#ControlEvents.KeyPressed ControlEvents.KeyReleased |
→ | Input.ButtonPressed Input.ButtonReleased |
Mostly equivalent.
|
#ControlEvents.MouseChanged | → | Input.ButtonPressed Input.ButtonReleased Input.CursorMoved Input.MouseWheelScrolled |
Not directly equivalent; may need to rewrite affected code. |
#GameEvents.EighthUpdateTick GameEvents.FourthUpdateTick GameEvents.HalfSecondTick GameEvents.QuarterSecondTick GameEvents.SecondUpdateTick |
→ | GameLoop.UpdateTicked | Mostly equivalent. You can use e.IsMultipleOf to choose an update rate (SecondUpdateTick = 2, FourthUpdateTick = 4, EighthUpdateTick = 8, QuarterSecondTick = 15, and HalfSecondTick = 30).
|
#GameEvents.FirstUpdateTick | → | GameLoop.GameLaunched | The new event is raised before the first update tick (the old one happened after it). To do something after the first update tick, use GameEvents.UpdateTicked with if (e.Ticks == 1). |
#GameEvents.UpdateTick | → | GameLoop.UpdateTicked | Equivalent. |
#GameEvents.OneSecondTick | → | GameLoop.OneSecondUpdateTicked | Equivalent. |
#GraphicsEvents.OnPostRenderEvent | → | Display.Rendered | Equivalent, except the new event isn't triggered during certain special cutscenes and minigames (e.g., the board game scene). |
#GraphicsEvents.OnPostRenderGuiEvent | → | Display.RenderedActiveMenu | Equivalent. |
#GraphicsEvents.OnPostRenderHudEvent | → | Display.RenderedHud | Equivalent. |
#GraphicsEvents.OnPreRenderEvent | → | Display.RenderingWorld | Equivalent. |
#GraphicsEvents.OnPreRenderGuiEvent | → | Display.RenderingActiveMenu | Equivalent. |
#GraphicsEvents.OnPreRenderHudEvent | → | Display.RenderingHud | Equivalent. |
#GraphicsEvents.Resize | → | Display.WindowResized | Equivalent. |
#InputEvents.ButtonPressed InputEvents.ButtonReleased |
→ | Input.ButtonPressed Input.ButtonReleased |
Mostly equivalent.
|
#LocationEvents.BuildingsChanged | → | World.BuildingListChanged | Equivalent. |
#LocationEvents.LocationsChanged | → | World.LocationListChanged | Equivalent. |
#LocationEvents.ObjectsChanged | → | World.ObjectListChanged | Equivalent. |
#MenuEvents.MenuChanged MenuEvents.MenuClosed |
→ | Display.MenuChanged | These caused a lot of confusion (e.g., MenuEvents.MenuClosed wasn't called when a menu was closed and immediately replaced), so they've been combined into one event which is called when a menu is opened, closed, or replaced. You can check the e.OldMenu and e.NewMenu event args to know what the change is (e.g., to match the old MenuEvents.MenuClosed, check if (e.NewMenu == null) ).
|
#MineEvents.MineLevelChanged | → | Player.Warped | Check if (e.NewLocation is MineShaft mine) to detect a mine level change (the new mine level will be mine.mineLevel ). Although the new event is still only called for the current player, that may change in a future version; make sure to check e.IsLocalPlayer if you only want to handle the current player.
|
#MultiplayerEvents.AfterMainBroadcast MultiplayerEvents.AfterMainSync MultiplayerEvents.BeforeMainBroadcast MultiplayerEvents.BeforeMainSync |
→ | none | No known mods use these. If you need them, consider replacing Game1.multiplayer with a delegating subclass. |
#PlayerEvents.InventoryChanged | → | Player.InventoryChanged | Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; make sure to check e.IsLocalPlayer if you only want to handle the current player. |
#PlayerEvents.LeveledUp | → | Player.LevelChanged | Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; make sure to check e.IsLocalPlayer if you only want to handle the current player. |
#PlayerEvents.Warped | → | Player.Warped | Mostly equivalent. The event arguments changed type, but should be straightforward to migrate. Although the new event is still only called for the current player, that may change in a future version; make sure to check e.IsLocalPlayer if you only want to handle the current player. |
#SaveEvents.AfterCreate | → | GameLoop.SaveCreated | Equivalent. |
#SaveEvents.AfterLoad | → | GameLoop.SaveLoaded | Equivalent. |
#SaveEvents.AfterReturnToTitle | → | GameLoop.ReturnedToTitle | Equivalent. |
#SaveEvents.AfterSave | → | GameLoop.Saved | Equivalent. |
#SaveEvents.BeforeCreate | → | GameLoop.SaveCreating | Equivalent. |
#SaveEvents.BeforeSave | → | GameLoop.Saving | Equivalent. |
#SpecialisedEvents.UnvalidatedUpdateTick | → | Specialised.UnvalidatedUpdateTicked | Equivalent. |
#TimeEvents.AfterDayStarted | → | GameLoop.DayStarted | Equivalent. |
#TimeEvents.TimeOfDayChanged | → | GameLoop.TimeChanged | Mostly equivalent. Change e.OldInt and e.NewInt to e.OldTime and e.NewTime respectively. |
Manifest version format
The manifest.json no longer allows versions in this form:
"Version": {
"MajorVersion": 1,
"MinorVersion": 0,
"PatchVersion": 0,
"Build": "beta"
}
Versions should be written in the standard string form instead:
"Version": "1.0.0-beta"
Version format
SMAPI no longer omits .0
patch numbers when formatting versions. For example, the console now shows SMAPI 3.0.0 instead of 3.0. That's more standard, improves compatibility with external tools, and reduces player confusion.
This doesn't affect most mod code. You may need to update your code if you use ISemanticVersion.ToString() and compare the output to a hardcoded two-part version string.