diff --git a/CHANGELOG.md b/CHANGELOG.md index cba5c7a0a..d2a3a2673 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Version 2.21.3 +* Fixed category tabs refreshed every frame, causing saplings to spin in the cultivator + ## Version 2.21.2 * Fixed for Valheim 0.219.14 (Bog Witch), older Valheim versions are not compatible diff --git a/JotunnLib/Managers/PieceManager.cs b/JotunnLib/Managers/PieceManager.cs index ea22f91a0..30a48b936 100644 --- a/JotunnLib/Managers/PieceManager.cs +++ b/JotunnLib/Managers/PieceManager.cs @@ -112,17 +112,10 @@ private static class Patches private static void Hud_Awake() => Instance.RefreshCategories(); [HarmonyPatch(typeof(Hud), nameof(Hud.UpdateBuild)), HarmonyPrefix] - private static void Hud_UpdateBuild() => Instance.RefreshCategories(); + private static void Hud_UpdateBuild() => Instance.RefreshCategoriesIfNeeded(); [HarmonyPatch(typeof(Hud), nameof(Hud.LateUpdate)), HarmonyPostfix] - private static void Hud_LateUpdate() - { - if (categoryRefreshNeeded) - { - categoryRefreshNeeded = false; - Instance.RefreshCategories(); - } - } + private static void Hud_LateUpdate() => Instance.RefreshCategoriesIfNeeded(); [HarmonyPatch(typeof(ObjectDB), nameof(ObjectDB.Awake)), HarmonyPostfix, HarmonyPriority(Priority.Low)] private static void RegisterCustomData(ObjectDB __instance) => Instance.RegisterCustomData(__instance); @@ -846,6 +839,15 @@ private GameObject CreateCategoryTab() return newTab; } + private void RefreshCategoriesIfNeeded() + { + if (categoryRefreshNeeded) + { + categoryRefreshNeeded = false; + RefreshCategories(); + } + } + /// /// Updates the piece categories, should be called after setting the m_category field of a piece. ///