diff --git a/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs b/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs index 54b91679..bda5f9c0 100644 --- a/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs +++ b/src/SMAPI/Framework/ModLoading/RewriteFacades/HarmonyInstanceFacade.cs @@ -34,6 +34,8 @@ namespace StardewModdingAPI.Framework.ModLoading.RewriteFacades if (original != null) original = original.GetDeclaredMember(); + if (!Constants.MonoModInit) + return null; // call Harmony 2.0 and show a detailed exception if it fails try { diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/MethodToAnotherStaticMethodRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/MethodToAnotherStaticMethodRewriter.cs index 8798ea61..6d04c816 100644 --- a/src/SMAPI/Framework/ModLoading/Rewriters/MethodToAnotherStaticMethodRewriter.cs +++ b/src/SMAPI/Framework/ModLoading/Rewriters/MethodToAnotherStaticMethodRewriter.cs @@ -39,23 +39,13 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters this.ToMethod = toMethod; } - /// Perform the predefined logic for a method if applicable. - /// The assembly module containing the instruction. - /// The method definition containing the instruction. - /// Replaces the type reference with a new one. - /// Returns whether the type was changed. - public InstructionHandleResult Handle(ModuleDefinition module, MethodDefinition method, Action replaceWith) - { - return InstructionHandleResult.None; - } - /// Perform the predefined logic for an instruction if applicable. /// The assembly module containing the instruction. /// The CIL processor. /// The instruction to handle. /// Replaces the type reference with a new one. /// Returns whether the type was changed. - public bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action replaceWith) + public override bool Handle(ModuleDefinition module, ILProcessor cil, Instruction instruction, Action replaceWith) { if (!this.IsMatch(instruction)) return false; @@ -75,6 +65,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters MethodReference methodRef = RewriteHelper.AsMethodReference(instruction); return methodRef != null + && methodRef.DeclaringType.FullName == this.FromType.FullName && this.FromMethodSelector.Invoke(methodRef); } }