diff --git a/docs/release-notes.md b/docs/release-notes.md index a900150a..80ce7d33 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -5,6 +5,7 @@ * Added mod page link to 'missing dependency' errors for the most common dependencies. * Restrict to Stardew Valley 1.3.33 or earlier (to avoid confusion when SDV 1.3.35 is released). * Fixed 'unknown mod' deprecation warnings showing a stack trace when developers mode not enabled. + * Fixed 'unknown mod' deprecation warnings when they occur in the Mod constructor. * For modders: * Fixed `Constants.SaveFolderName` and `CurrentSavePath` not available during early load stages when using `Specialised.LoadStageChanged` event. diff --git a/src/SMAPI/Framework/ModRegistry.cs b/src/SMAPI/Framework/ModRegistry.cs index e9ceb66e..5be33cb4 100644 --- a/src/SMAPI/Framework/ModRegistry.cs +++ b/src/SMAPI/Framework/ModRegistry.cs @@ -33,8 +33,14 @@ namespace StardewModdingAPI.Framework public void Add(IModMetadata metadata) { this.Mods.Add(metadata); - if (!metadata.IsContentPack) - this.ModNamesByAssembly[metadata.Mod.GetType().Assembly.FullName] = metadata; + } + + /// Track a mod's assembly for use via . + /// The mod metadata. + /// The mod assembly. + public void TrackAssemblies(IModMetadata metadata, Assembly modAssembly) + { + this.ModNamesByAssembly[modAssembly.FullName] = metadata; } /// Get metadata for all loaded mods. diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 27c0c40b..46e1de8d 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -977,6 +977,7 @@ namespace StardewModdingAPI.Framework try { modAssembly = assemblyLoader.Load(mod, assemblyPath, assumeCompatible: mod.DataRecord?.Status == ModStatus.AssumeCompatible); + this.ModRegistry.TrackAssemblies(mod, modAssembly); } catch (IncompatibleInstructionException) // details already in trace logs {