Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Extream Durability Penalty v1.1.1
ExtreamDurabilityPenalty.dll
Decompiled a month agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("DurabilityPenalty")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DurabilityPenalty")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2b4a8525-7402-4e66-846f-eef2fe15cd99")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace TestRepair { [BepInPlugin("test.repair", "Test Repair", "1.0.0")] [BepInProcess("valheim.exe")] public class TestMod : BaseUnityPlugin { private Harmony _harmony; private void Awake() { _harmony = Harmony.CreateAndPatchAll(typeof(TestMod), (string)null); Debug.Log((object)"TestMod загружен"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Player), "Repair")] internal class Patch { private static void Postfix(Player __instance) { Debug.Log((object)"Player.Repair вызван!"); } } } namespace DurabilityPenaltyMod { [BepInPlugin("com.B2Lade.extreamdurabilitypenalty", "Extream Durability Penatlty", "1.1.1")] [BepInProcess("valheim.exe")] public class MainMod : BaseUnityPlugin { public static ConfigEntry<float> DurabilityLossPercent; public static ConfigEntry<bool> ShowLogMessages; public static ConfigEntry<float> DestroyThresholdPercent; private Harmony _harmony; private void Awake() { DurabilityLossPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DurabilityLossPercent", 5f, "Percentage by which restored strength decreases with each repair (0-100)"); ShowLogMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowLogMessages", true, "Show messages in console"); DestroyThresholdPercent = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DestroyThresholdPercent", 5f, "If durability after repair is less than this percentage of maximum - item is destroyed"); _harmony = Harmony.CreateAndPatchAll(typeof(MainMod).Assembly, (string)null); Debug.Log((object)"[ExtreamDurabilityPenalty] Loaded"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(InventoryGui), "CanRepair")] public static class Patch_CanRepair { private static Dictionary<ItemData, int> repairCounts = new Dictionary<ItemData, int>(); private static Dictionary<ItemData, float> lastRepairTime = new Dictionary<ItemData, float>(); private static void Postfix(InventoryGui __instance, ItemData item, ref bool __result) { if (!__result || item == null) { return; } float time = Time.time; if (lastRepairTime.TryGetValue(item, out var value) && time - value < 0.5f) { return; } lastRepairTime[item] = time; float num = MainMod.DurabilityLossPercent.Value / 100f; float num2 = MainMod.DestroyThresholdPercent.Value / 100f; if (num <= 0f) { return; } if (!repairCounts.ContainsKey(item)) { repairCounts[item] = 0; } int num3 = repairCounts[item]; float num4 = 1f - (float)num3 * num; if (num4 < num2) { item.m_shared.m_destroyBroken = true; item.m_durability = 0f; if (MainMod.ShowLogMessages.Value) { Debug.Log((object)("[ExtreamDurabilityPenalty] " + item.m_shared.m_name + " is critically worn out and will be destroyed!")); } repairCounts.Remove(item); return; } if (num4 < 0.1f) { num4 = 0.1f; } float maxDurability = item.GetMaxDurability(item.m_quality); float num5 = maxDurability * num4; if (num5 > maxDurability) { num5 = maxDurability; } item.m_durability = num5; repairCounts[item] = num3 + 1; if (MainMod.ShowLogMessages.Value) { Debug.Log((object)$"[DurabilityPenalty] Repair: {item.m_shared.m_name} — item strength is {num5:F0}/{maxDurability:F0} (Repairs Count: {num3 + 1})"); } } } }