diff --git a/stardew-access/HarmonyPatches.cs b/stardew-access/HarmonyPatches.cs index 4a4ffbd..ab4f304 100644 --- a/stardew-access/HarmonyPatches.cs +++ b/stardew-access/HarmonyPatches.cs @@ -309,8 +309,8 @@ namespace stardew_access ); harmony.Patch( - original: AccessTools.Method(typeof(TrashBear), nameof(TrashBear.draw), new Type[] { typeof(SpriteBatch) }), - prefix: new HarmonyMethod(typeof(TrashBearPatch), nameof(TrashBearPatch.DrawPatch)) + original: AccessTools.Method(typeof(TrashBear), nameof(TrashBear.checkAction)), + postfix: new HarmonyMethod(typeof(TrashBearPatch), nameof(TrashBearPatch.CheckActionPatch)) ); } } diff --git a/stardew-access/Patches/MiscPatches/TrashBearPatch.cs b/stardew-access/Patches/MiscPatches/TrashBearPatch.cs index ad2592a..75a5667 100644 --- a/stardew-access/Patches/MiscPatches/TrashBearPatch.cs +++ b/stardew-access/Patches/MiscPatches/TrashBearPatch.cs @@ -1,22 +1,23 @@ using StardewValley; +using StardewValley.Characters; namespace stardew_access.Patches { internal class TrashBearPatch { - internal static void DrawPatch(int ___itemWantedIndex, int ___showWantBubbleTimer) + internal static void CheckActionPatch(TrashBear __instance, bool __result, int ___itemWantedIndex, int ___showWantBubbleTimer) { try { - if (___showWantBubbleTimer >= 2900) - { - string itemName = Game1.objectInformation[___itemWantedIndex].Split('/')[4]; - MainClass.ScreenReader.Say($"Trash Bear wants {itemName}!", true); - } + if (__result) return; // The true `true` value of __result indicates the bear is interactable i.e. when giving the bear the wanted item + if (__instance.sprite.Value.CurrentAnimation != null) return; + + string itemName = Game1.objectInformation[___itemWantedIndex].Split('/')[4]; + MainClass.ScreenReader.Say($"Trash Bear wants {itemName}!", true); } catch (Exception e) { - MainClass.ErrorLog($"An error occured TrashBearPatch::DrawPatch():\n{e.Message}\n{e.StackTrace}"); + MainClass.ErrorLog($"An error occured TrashBearPatch::CheckActionPatch():\n{e.Message}\n{e.StackTrace}"); } } }