From c7d16f7fc93a124032f48054e1118702c4641bd3 Mon Sep 17 00:00:00 2001 From: ang-xd Date: Thu, 13 Feb 2025 17:43:24 -0500 Subject: [PATCH] Try fix console spam bug --- MiraAPI/Events/MiraEventManager.cs | 1 - MiraAPI/Patches/Events/CanUsePatches.cs | 14 ++++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/MiraAPI/Events/MiraEventManager.cs b/MiraAPI/Events/MiraEventManager.cs index f613cd5..eff933d 100644 --- a/MiraAPI/Events/MiraEventManager.cs +++ b/MiraAPI/Events/MiraEventManager.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using Reactor.Utilities; namespace MiraAPI.Events; diff --git a/MiraAPI/Patches/Events/CanUsePatches.cs b/MiraAPI/Patches/Events/CanUsePatches.cs index 56a88e6..aa80fd7 100644 --- a/MiraAPI/Patches/Events/CanUsePatches.cs +++ b/MiraAPI/Patches/Events/CanUsePatches.cs @@ -26,11 +26,17 @@ public static class CanUsePatches [HarmonyPrefix] public static bool CanUsePatch(Il2CppSystem.Object __instance, [HarmonyArgument(0)] NetworkedPlayerInfo pc, [HarmonyArgument(1)] out bool canUse, [HarmonyArgument(2)] out bool couldUse) { - var @event = new PlayerCanUseEvent(__instance.Cast()); - MiraEventManager.InvokeEvent(@event); - canUse = couldUse = false; - return !@event.IsCancelled; + IUsable usable = __instance.Cast(); + if (usable != null) + { + var @event = new PlayerCanUseEvent(__instance.Cast()); + MiraEventManager.InvokeEvent(@event); + + return !@event.IsCancelled; + } + + return true; } }