fix error loading .xnb files from the local mod folder since SMAPI 3.0

This commit is contained in:
Jesse Plamondon-Willard 2021-07-20 22:18:57 -04:00
parent defa1b9a95
commit c74702b027
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 6 additions and 1 deletions

View File

@ -12,6 +12,9 @@
* Added error message if you manually install the wrong SMAPI bitness (e.g. 32-bit SMAPI with 64-bit game).
* Fixed intermittent error if a mod fetches mod-provided APIs asynchronously.
* For mod authors:
* Fixed error loading `.xnb` files from the local mod folder since SMAPI 3.0.
## 3.11.0
Released 09 July 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/53514295).

View File

@ -77,6 +77,8 @@ namespace StardewModdingAPI.Framework.ContentManagers
/// <inheritdoc />
public override T Load<T>(string assetName, LanguageCode language, bool useCache)
{
// normalize key
bool isXnbFile = Path.GetExtension(assetName).ToLower() == ".xnb";
assetName = this.AssertAndNormalizeAssetName(assetName);
// disable caching
@ -108,7 +110,7 @@ namespace StardewModdingAPI.Framework.ContentManagers
try
{
// get file
FileInfo file = this.GetModFile(assetName);
FileInfo file = this.GetModFile(isXnbFile ? $"{assetName}.xnb" : assetName); // .xnb extension is stripped from asset names passed to the content manager
if (!file.Exists)
throw GetContentError("the specified path doesn't exist.");