Skip to content

Commit

Permalink
fix: Stop Error Spam (#528)
Browse files Browse the repository at this point in the history
Switch to Prefix so CraftData stops logging errors when custon recipes not found the first time.
  • Loading branch information
MrPurple6411 committed Jan 8, 2024
1 parent 48d9b00 commit 9bad417
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions Nautilus/Patchers/CraftDataPatcher_Subnautica.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit 9bad417

Please sign in to comment.