From 9bad4170e248cf00dc81263331337c664f2ef4d7 Mon Sep 17 00:00:00 2001 From: Joshua Gibbs Date: Mon, 8 Jan 2024 15:43:34 -0700 Subject: [PATCH] fix: Stop Error Spam (#528) Switch to Prefix so CraftData stops logging errors when custon recipes not found the first time. --- Nautilus/Patchers/CraftDataPatcher_Subnautica.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Nautilus/Patchers/CraftDataPatcher_Subnautica.cs b/Nautilus/Patchers/CraftDataPatcher_Subnautica.cs index 51641da4..bb6ab546 100644 --- a/Nautilus/Patchers/CraftDataPatcher_Subnautica.cs +++ b/Nautilus/Patchers/CraftDataPatcher_Subnautica.cs @@ -150,14 +150,12 @@ private static void GetBuildablePrefix(TechType recipe) PatchUtils.PatchList(CraftData.buildables, CustomBuildables); } - [HarmonyPostfix] - [HarmonyPatch(typeof(CraftData), nameof(CraftData.Get))] - private static void GetRecipePostfix(TechType techType, ref ITechData __result) + [HarmonyPatch(typeof(CraftData), nameof(CraftData.Get)), HarmonyPrefix, HarmonyPriority(Priority.First)] + private static void GetRecipePrefix(TechType techType) { - if (CustomRecipeData.TryGetValue(techType, out var customTechData) && (__result == null || !customTechData.SameAs(__result))) + if (CustomRecipeData.TryGetValue(techType, out var customTechData) && (!CraftData.techData.TryGetValue(techType, out var current) || !customTechData.SameAs(current))) { CraftData.techData[techType] = customTechData.ConvertToTechData(techType); - __result = customTechData; } } }