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 GracefulLanding v1.2.3
GracefulLanding.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using ConditionalConfigSync; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("GracefulLanding")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Crystal")] [assembly: AssemblyProduct("GracefulLanding")] [assembly: AssemblyCopyright("Copyright © 2026 Crystal Ferrai")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("59e3a8b0-42d8-4f95-b9e2-e61bbe7f58f4")] [assembly: AssemblyFileVersion("1.2.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.2.3.0")] namespace GracefulLanding; [BepInPlugin("dev.crystal.gracefullanding", "Graceful Landing", "1.2.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class GracefulLandingPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Character))] private static class Character_Patches { [HarmonyPatch("UpdateGroundContact")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> UpdateGroundContact_Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_R4) { float num = (float)instruction.operand; if (num != 4f) { if (num != 16f) { if (num == 100f) { instruction.operand = MaxDamageAmount.Value; } } else { instruction.operand = MaxDamageHeight.Value; } } else { instruction.operand = MinDamageHeight.Value; } } yield return instruction; } } } public const string ModId = "dev.crystal.gracefullanding"; public const string ModName = "Graceful Landing"; public const string ModVersion = "1.2.3.0"; internal static readonly ConfigSync ConfigSync = new ConfigSync("dev.crystal.gracefullanding") { DisplayName = "Graceful Landing", CurrentVersion = "1.2.3.0", MinimumRequiredVersion = "1.2.3.0", ModRequired = true, ModRequirementMode = (ModRequirementMode)1 }; public static ConfigEntry<float> MinDamageHeight; public static ConfigEntry<float> MaxDamageHeight; public static ConfigEntry<float> MaxDamageAmount; private static Harmony sCharacterHarmony; private void Awake() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown MinDamageHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Falling", "MinDamageHeight", 8f, "The minimum distance you must fall to receive any fall damage. Allowed range 1-10000. Game default 4. [The value will be enforced on a server.]"); MinDamageHeight.SettingChanged += Falling_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(MinDamageHeight, (ConfigSyncMode)0); MaxDamageHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Falling", "MaxDamageHeight", 64f, "The minimum distance you must to receive maximum fall damage. Allowed range 1-10000. Must be equal to or higher than MinDamageHeight. Game default 16. [The value will be enforced on a server.]"); MaxDamageHeight.SettingChanged += Falling_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(MaxDamageHeight, (ConfigSyncMode)0); MaxDamageAmount = ((BaseUnityPlugin)this).Config.Bind<float>("Falling", "MaxDamageAmount", 100f, "The maximum fall damage that can be received. Allowed range 0-10000. Game default 100. [The value will be enforced on a server.]"); MaxDamageAmount.SettingChanged += Falling_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(MaxDamageAmount, (ConfigSyncMode)0); ClampConfig(); sCharacterHarmony = new Harmony("dev.crystal.gracefullanding_Character"); sCharacterHarmony.PatchAll(typeof(Character_Patches)); } private void OnDestroy() { sCharacterHarmony.UnpatchSelf(); } private static void ClampConfig() { if (MinDamageHeight.Value < 1f) { MinDamageHeight.Value = 1f; } if (MinDamageHeight.Value > 10000f) { MinDamageHeight.Value = 10000f; } if (MaxDamageHeight.Value < MinDamageHeight.Value) { MaxDamageHeight.Value = MinDamageHeight.Value; } if (MaxDamageHeight.Value > 10000f) { MaxDamageHeight.Value = 10000f; } if (MaxDamageAmount.Value < 0f) { MaxDamageAmount.Value = 0f; } if (MaxDamageAmount.Value > 10000f) { MaxDamageAmount.Value = 10000f; } } private void Falling_SettingChanged(object sender, EventArgs e) { ClampConfig(); sCharacterHarmony.UnpatchSelf(); sCharacterHarmony.PatchAll(typeof(Character_Patches)); } }