Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop Error Spam #528

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Switch to Prefix so CraftData stops logging errors when custon recipe…
…s not found the first time.
  • Loading branch information
MrPurple6411 committed Jan 7, 2024
commit e219b8691b37f3ca30ba50f6522ddfe659cc8f33
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