diff --git a/AQualityMod/Mod.cs b/AQualityMod/Mod.cs index 73e2259b4..ed4a47e92 100644 --- a/AQualityMod/Mod.cs +++ b/AQualityMod/Mod.cs @@ -71,11 +71,9 @@ public static class CaskObjectDropInPatch { public static IEnumerable Transpiler(ILGenerator gen, MethodBase original, IEnumerable insns) { - Log.Debug("meth:" + original); List ret = new(); foreach (var insn in insns) { - Log.Debug("insn:" + insn); if (insn.opcode == OpCodes.Ldc_I4_4) { insn.opcode = OpCodes.Ldc_I4_6; diff --git a/AQualityMod/manifest.json b/AQualityMod/manifest.json index 22cc61dc3..1770b1d96 100644 --- a/AQualityMod/manifest.json +++ b/AQualityMod/manifest.json @@ -1,7 +1,7 @@ { "Name": "A Quality Mod", "Author": "spacechase0", - "Version": "1.0.0", + "Version": "1.0.1", "Description": "...", "UniqueID": "spacechase0.AQualityMod", "EntryDll": "AQualityMod.dll", diff --git a/SpaceCore/Framework/Commands.cs b/SpaceCore/Framework/Commands.cs index 867a7cf45..76de22a90 100644 --- a/SpaceCore/Framework/Commands.cs +++ b/SpaceCore/Framework/Commands.cs @@ -1,6 +1,7 @@ using System.IO; using System.Linq; using System.Text; +using HarmonyLib; using Microsoft.Xna.Framework.Graphics; using SpaceShared; using StardewModdingAPI; @@ -16,6 +17,7 @@ internal static void Register() Command.Register("asset_invalidate", Commands.InvalidateCommand); Command.Register("exttilesheets_dump", Commands.DumpTilesheetsCommand); Command.Register("dump_spacecore_skills", Commands.DumpSkills); + Command.Register("harmony_invalidate", Commands.HarmonyInvalidate); //Command.register( "test", ( args ) => Game1.player.addItemByMenuIfNecessary( new TestObject() ) ); //SpaceCore.modTypes.Add( typeof( TestObject ) ); } @@ -150,5 +152,27 @@ private static void DumpTilesheetsCommand(string[] args) } } } + + private static void HarmonyInvalidate(string[] args) + { + if (args.Length == 0) + { + Log.Info("You must specify a method, like: harmony_invalidate StardewValley.CraftingRecipe:consumeIngredients"); + return; + } + + var meth = AccessTools.Method(args[0]); + if (meth == null) + { + Log.Debug("Method not found; note this doesn't work with ambiguous matches"); + return; + } + + // TODO: Unpatch/repatch the same methods instead of constantly adding new patches + var dummyPrefix = AccessTools.Method(typeof(Commands), nameof(DummyPrefixForHarmonyInvalidate)); + SpaceCore.Instance.Harmony.Patch(meth, new HarmonyMethod(dummyPrefix)); + } + + private static void DummyPrefixForHarmonyInvalidate() { } } } diff --git a/SpaceCore/SpaceCore.cs b/SpaceCore/SpaceCore.cs index 20944f831..3d8e15170 100644 --- a/SpaceCore/SpaceCore.cs +++ b/SpaceCore/SpaceCore.cs @@ -65,7 +65,7 @@ internal class SpaceCore : Mod /********* ** Fields *********/ - private Harmony Harmony; + internal Harmony Harmony; /// Handles migrating legacy data for a save file. private LegacyDataMigrator LegacyDataMigrator; diff --git a/Spacechase0.Stardew.sln b/Spacechase0.Stardew.sln index 760e51953..b55803a1d 100644 --- a/Spacechase0.Stardew.sln +++ b/Spacechase0.Stardew.sln @@ -565,7 +565,6 @@ Global {AACF284D-8352-4727-9F9E-9916BA2266AF} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} {1D6C6511-624C-4332-9E70-486F81A28888} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} {CB5BB6E2-D963-4A27-A3B9-1E4BB068983B} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} - {B5127FFB-A748-44FF-882E-5279B0F7B279} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} {19EB9934-6F62-401B-9447-3661BAE212A0} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} {7AA1C02E-9099-4C1A-B8AF-AC1966B337E5} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA} {104FCF4D-7776-4C16-94CE-EDE8209D6D9F} = {8FEFBE16-BBBC-4EA0-829E-E5DCF15F0DFA}