Skip to content

Commit 79e2c16

Browse files
committed
update rewriters for Stardew Valley 1.6.4
1.6.4 adds an optional 'includeEventActor' argument to Game1 methods for searching NPCs. This also drops support for 1.6.0–1.6.3, since it'd be tricky to rewrite for both without introducing potential regressions (and since 1.6.4 fixes NPC duplication issues).
1 parent bebf4ce commit 79e2c16

File tree

4 files changed

+19
-27
lines changed

4 files changed

+19
-27
lines changed

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Release notes
44
## Upcoming release
55
* For players:
6+
* Updated for Stardew Valley 1.6.4. **This drops compatibility with Stardew Valley 1.6.0–1.6.3.**
67
* The installer now deletes obsolete files from very old SMAPI versions again. (This was removed in SMAPI 4.0, but many players still had very old versions.)
78
* The installer now deletes Error Handler automatically if it's at the default path.
89

src/SMAPI/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static class Constants
6565
public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion(EarlyConstants.RawApiVersion);
6666

6767
/// <summary>The minimum supported version of Stardew Valley.</summary>
68-
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.6.0");
68+
public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.6.4");
6969

7070
/// <summary>The maximum supported version of Stardew Valley, if any.</summary>
7171
public static ISemanticVersion? MaximumGameVersion { get; } = null;

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/Game1Facade.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Diagnostics.CodeAnalysis;
34
using Microsoft.Xna.Framework;
@@ -116,11 +117,26 @@ public static void drawObjectQuestionDialogue(string dialogue, List<Response>? c
116117
Game1.drawObjectQuestionDialogue(dialogue, choices?.ToArray());
117118
}
118119

119-
public static NPC getCharacterFromName(string name, bool mustBeVillager = true, bool useLocationsListOnly = false)
120+
public new static NPC? getCharacterFromName(string name, bool mustBeVillager = true)
120121
{
121122
return Game1.getCharacterFromName(name, mustBeVillager);
122123
}
123124

125+
public static T? getCharacterFromName<T>(string name, bool mustBeVillager = true) where T : NPC
126+
{
127+
return Game1.getCharacterFromName<T>(name, mustBeVillager);
128+
}
129+
130+
public static T? GetCharacterOfType<T>() where T : NPC
131+
{
132+
return Game1.GetCharacterOfType<T>();
133+
}
134+
135+
public static T? GetCharacterWhere<T>(Func<T, bool> check) where T : NPC
136+
{
137+
return Game1.GetCharacterWhere(check);
138+
}
139+
124140
public static int getModeratelyDarkTime()
125141
{
126142
return Game1.getModeratelyDarkTime(Game1.currentLocation);

src/SMAPI/Framework/ModLoading/Rewriters/StardewValley_1_6/UtilityFacade.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Linq;
5-
using System.Reflection;
65
using Microsoft.Xna.Framework;
76
using StardewModdingAPI.Framework.ModLoading.Framework;
87
using StardewValley;
@@ -47,30 +46,6 @@ public static void ForAllLocations(Action<GameLocation> action)
4746
});
4847
}
4948

50-
public new static void ForEachCharacter(Func<NPC, bool> action, bool includeEventActors = false)
51-
{
52-
// Stardew Valley 1.6.3 added an optional parameter to ForEachCharacter, so mods compiled in 1.6.3 won't
53-
// run in 1.6.2 and earlier. We can't just call the method directly either since SMAPI itself is compiled
54-
// for 1.6.3+ too.
55-
56-
MethodInfo method =
57-
typeof(Utility).GetMethod(nameof(Utility.ForEachCharacter))
58-
?? throw new InvalidOperationException($"Can't find method {nameof(Utility)}.{nameof(Utility.ForEachCharacter)} for compatibility rewrite.");
59-
method.Invoke(null, new object[] { action });
60-
}
61-
62-
public new static void ForEachVillager(Func<NPC, bool> action, bool includeEventActors = false)
63-
{
64-
// Stardew Valley 1.6.3 added an optional parameter to ForEachVillager, so mods compiled in 1.6.3 won't
65-
// run in 1.6.2 and earlier. We can't just call the method directly either since SMAPI itself is compiled
66-
// for 1.6.3+ too.
67-
68-
MethodInfo method =
69-
typeof(Utility).GetMethod(nameof(Utility.ForEachVillager))
70-
?? throw new InvalidOperationException($"Can't find method {nameof(Utility)}.{nameof(Utility.ForEachVillager)} for compatibility rewrite.");
71-
method.Invoke(null, new object[] { action });
72-
}
73-
7449
public new static DisposableList<NPC> getAllCharacters()
7550
{
7651
return new DisposableList<NPC>(Utility.getAllCharacters());

0 commit comments

Comments
 (0)