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 DigDeeper v1.3.1
DigDeeper.dll
Decompiled 3 weeks 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("DigDeeper")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Crystal")] [assembly: AssemblyProduct("DigDeeper")] [assembly: AssemblyCopyright("Copyright © 2026 Crystal Ferrai")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("257c1abb-2713-468a-8321-84c583805faa")] [assembly: AssemblyFileVersion("1.3.1.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.3.1.0")] namespace DigDeeper; [BepInPlugin("dev.crystal.digdeeper", "Dig Deeper", "1.3.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInProcess("valheim.exe")] [BepInProcess("valheim_server.exe")] public class DigDeeperPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(Heightmap))] private static class Heightmap_Patches { private enum TranspilerState { Searching, Replacing } [HarmonyPatch("LevelTerrain")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> LevelTerrain_Transpiler(IEnumerable<CodeInstruction> instructions) { TranspilerState state = TranspilerState.Searching; CodeInstruction valueInstruction = null; foreach (CodeInstruction instruction in instructions) { switch (state) { case TranspilerState.Searching: if (instruction.opcode == OpCodes.Ldc_R8 && (double)instruction.operand == 8.0) { valueInstruction = instruction; state = TranspilerState.Replacing; } else { yield return instruction; } break; case TranspilerState.Replacing: if (instruction.opcode == OpCodes.Sub) { valueInstruction.operand = (double)MaximumDepth.Value; yield return valueInstruction; } else if (instruction.opcode == OpCodes.Add) { valueInstruction.operand = (double)MaximumHeight.Value; yield return valueInstruction; } yield return instruction; valueInstruction = null; state = TranspilerState.Searching; break; } } } } [HarmonyPatch(typeof(TerrainComp))] private static class TerrainComp_Patches { private enum TranspilerState { Searching, Replacing } [HarmonyPatch("ApplyToHeightmap")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> ApplyToHeightmap_Transpiler(IEnumerable<CodeInstruction> instructions) { TranspilerState state = TranspilerState.Searching; CodeInstruction valueInstruction = null; foreach (CodeInstruction instruction in instructions) { switch (state) { case TranspilerState.Searching: if (instruction.opcode == OpCodes.Ldc_R4 && (float)instruction.operand == 8f) { valueInstruction = instruction; state = TranspilerState.Replacing; } else { yield return instruction; } break; case TranspilerState.Replacing: if (instruction.opcode == OpCodes.Sub) { valueInstruction.operand = MaximumDepth.Value; yield return valueInstruction; } else if (instruction.opcode == OpCodes.Add) { valueInstruction.operand = MaximumHeight.Value; yield return valueInstruction; } yield return instruction; valueInstruction = null; state = TranspilerState.Searching; break; } } } [HarmonyPatch("LevelTerrain")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> LevelTerrain_Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_R4) { if ((float)instruction.operand == 8f) { instruction.operand = MaximumHeight.Value; } else if ((float)instruction.operand == -8f) { instruction.operand = 0f - MaximumDepth.Value; } } yield return instruction; } } [HarmonyPatch("RaiseTerrain")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> RaiseTerrain_Transpiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (instruction.opcode == OpCodes.Ldc_R4) { if ((float)instruction.operand == 8f) { instruction.operand = MaximumHeight.Value; } else if ((float)instruction.operand == -8f) { instruction.operand = 0f - MaximumDepth.Value; } } yield return instruction; } } } public const string ModId = "dev.crystal.digdeeper"; public const string ModName = "Dig Deeper"; public const string ModVersion = "1.3.1.0"; internal static readonly ConfigSync ConfigSync = new ConfigSync("dev.crystal.digdeeper") { DisplayName = "Dig Deeper", CurrentVersion = "1.3.1.0", MinimumRequiredVersion = "1.3.1.0", ModRequired = true, ModRequirementMode = (ModRequirementMode)0 }; public static ConfigEntry<float> MaximumDepth; public static ConfigEntry<float> MaximumHeight; private static Harmony sHeightmapHarmony; private static Harmony sTerrainCompHarmony; private void Awake() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown MaximumDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Digging", "MaximumDepth", 20f, "The maximum depth you can dig below the terrain surface. Range 0-128. Game default is 8. [The value will be enforced on a server.]"); MaximumDepth.SettingChanged += Config_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(MaximumDepth, (ConfigSyncMode)0); MaximumHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Digging", "MaximumHeight", 8f, "The maximum height you can raise the terrain. Range 0-128. Game default is 8. [The value will be enforced on a server.]"); MaximumHeight.SettingChanged += Config_SettingChanged; ((ConditionalConfigSync)ConfigSync).AddConfigEntry<float>(MaximumHeight, (ConfigSyncMode)0); ClampConfig(); sHeightmapHarmony = new Harmony("dev.crystal.digdeeper_Heightmap"); sHeightmapHarmony.PatchAll(typeof(Heightmap_Patches)); sTerrainCompHarmony = new Harmony("dev.crystal.digdeeper_TerrainComp"); sTerrainCompHarmony.PatchAll(typeof(TerrainComp_Patches)); } private void OnDestroy() { sHeightmapHarmony.UnpatchSelf(); sTerrainCompHarmony.UnpatchSelf(); } private static void ClampConfig() { if (MaximumDepth.Value < 0f) { MaximumDepth.Value = 0f; } if (MaximumDepth.Value > 128f) { MaximumDepth.Value = 128f; } if (MaximumHeight.Value < 0f) { MaximumHeight.Value = 0f; } if (MaximumHeight.Value > 128f) { MaximumHeight.Value = 128f; } } private static void Config_SettingChanged(object sender, EventArgs e) { ClampConfig(); sHeightmapHarmony.UnpatchSelf(); sHeightmapHarmony.PatchAll(typeof(Heightmap_Patches)); sTerrainCompHarmony.UnpatchSelf(); sTerrainCompHarmony.PatchAll(typeof(TerrainComp_Patches)); } }