From 842af2fd4f0dc878c21c0d8c5ab0873468e0c836 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 11 Nov 2026 14:57:38 +0100 Subject: [PATCH] fix(alfar): hair and beard never attach, no flash on equipment change --- JotunnModStub/Alfar/AlfarPatches.cs | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/JotunnModStub/Alfar/AlfarPatches.cs b/JotunnModStub/Alfar/AlfarPatches.cs index 5d5e5ea..73864de 100644 --- a/JotunnModStub/Alfar/AlfarPatches.cs +++ b/JotunnModStub/Alfar/AlfarPatches.cs @@ -38,6 +38,37 @@ namespace RacesOfValheim } } + /// + /// Hair and beard never attach to an Alfr. Every equipment change makes the game write the + /// profile's hair back (Humanoid.SetupVisEquipment), and ApplyHairless only clears it on its + /// 0.5s pass, so players saw the hair flash in for a moment. Zeroing the hash here, where + /// VisEquipment spawns the model, means it never appears. Covers remote players too, since + /// their visuals go through the same call. + /// + [HarmonyPatch(typeof(VisEquipment), "SetHairEquipped")] + public static class Alfar_SetHairEquipped_Patch + { + public static void Prefix(VisEquipment __instance, ref int hash) + { + if (hash != 0 && IsAlfarVis(__instance)) hash = 0; + } + } + + [HarmonyPatch(typeof(VisEquipment), "SetBeardEquipped")] + public static class Alfar_SetBeardEquipped_Patch + { + public static void Prefix(VisEquipment __instance, ref int hash) + { + if (hash != 0 && IsAlfarVis(__instance)) hash = 0; + } + } + + private static bool IsAlfarVis(VisEquipment vis) + { + Player player = vis.GetComponent(); + return player != null && AlfarVisuals.IsAlfarPlayer(player); + } + /// /// The character preview on the main menu is a Player too, with the saved race in its custom data /// and no ZNetView. Its Update may never run, so a small driver on it keeps the look: skin, hair,