The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of PEAK Nature Items v0.2.1
tony4twentys-PEAK Nature Items.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PEAK Nature Items")] [assembly: AssemblyDescription("PEAK Nature Items - Configure item spawns in natural locations like mushroom clusters, berry bushes, trees, and vines")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PEAK Nature Items")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("d8a3e99a-afbf-4dc3-aa36-ce493ed12580")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace PEAKNatureItems; public class ModItemInfo { public string ModGUID { get; set; } public ushort ItemID { get; set; } public string ItemName { get; set; } public int DefaultWeight { get; set; } public SpawnPool[] DefaultPools { get; set; } } [BepInPlugin("tony4twentys.PEAK_Nature_Items", "PEAK Nature Items", "1.1.1")] public class PEAKNatureItemsPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(LootData), "PopulateLootData")] public static class LootData_PopulateLootData_Patch { public static void Postfix() { try { OverrideItemWeights(); } catch (Exception arg) { Debug.LogError((object)$"[PEAK Nature Items] Error in PopulateLootData patch: {arg}"); } } } private static ConfigFile config; private static Dictionary<ushort, ConfigEntry<int>> itemWeights = new Dictionary<ushort, ConfigEntry<int>>(); private static Dictionary<ushort, ConfigEntry<string>> itemPools = new Dictionary<ushort, ConfigEntry<string>>(); private static ConfigEntry<bool> enableDetailedLogging; private static Dictionary<string, List<ModItemInfo>> DetectedMods = new Dictionary<string, List<ModItemInfo>> { { "spidersgeorg-RarityRoulette", new List<ModItemInfo> { new ModItemInfo { ModGUID = "spidersgeorg-RarityRoulette", ItemID = 39393, ItemName = "Revolver", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] } } }, { "com.khakixd.firstaid", new List<ModItemInfo> { new ModItemInfo { ModGUID = "com.khakixd.firstaid", ItemID = 33647, ItemName = "Melatonin", DefaultWeight = 50, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.khakixd.firstaid", ItemID = 22534, ItemName = "Pain Killers", DefaultWeight = 20, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] } } }, { "com.github.quackandcheese.Glizzy", new List<ModItemInfo> { new ModItemInfo { ModGUID = "com.github.quackandcheese.Glizzy", ItemID = 33466, ItemName = "Glizzy", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] } } }, { "com.github.BurningSulphur.Scouting4Food", new List<ModItemInfo> { new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 21719, ItemName = "Sticky Plaster", DefaultWeight = 50, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 6082, ItemName = "Ice Cream", DefaultWeight = 30, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 43181, ItemName = "Popscicle Stick", DefaultWeight = 0, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 40176, ItemName = "Gobstopper", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 62465, ItemName = "Salty Chrisps", DefaultWeight = 30, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 42692, ItemName = "Flaming Hot Chrips", DefaultWeight = 30, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 49222, ItemName = "Climbers Chalk", DefaultWeight = 20, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 32214, ItemName = "Anti-Grav Shroom", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 28995, ItemName = "Can O Beans", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 31890, ItemName = "Extra Extreme Energy Drink", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 60459, ItemName = "Watermelon", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[2] { (SpawnPool)32, (SpawnPool)256 } }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 29337, ItemName = "Watermelon Slice", DefaultWeight = 30, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 27734, ItemName = "Chicken Drumstick", DefaultWeight = 15, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] }, new ModItemInfo { ModGUID = "com.github.BurningSulphur.Scouting4Food", ItemID = 45382, ItemName = "Ice Axe", DefaultWeight = 30, DefaultPools = (SpawnPool[])(object)new SpawnPool[0] } } } }; private static Dictionary<string, bool> ModLoadedStatus = new Dictionary<string, bool>(); private static readonly Dictionary<ushort, string> ItemNames = new Dictionary<ushort, string> { { 0, "Airplane Food" }, { 1, "Anti-Rope Spool" }, { 2, "Antidote" }, { 3, "Green Crispberry" }, { 4, "Red Crispberry" }, { 5, "Yellow Crispberry" }, { 6, "Backpack" }, { 7, "Bandages" }, { 8, "Beehive" }, { 9, "Blue Berrynana" }, { 10, "Brown Berrynana" }, { 11, "Pink Berrynana" }, { 12, "Yellow Berrynana" }, { 13, "Bing Bong" }, { 14, "Binoculars" }, { 15, "Bugle" }, { 16, "Bugle of Friendship" }, { 17, "Chain Launcher" }, { 18, "Piton" }, { 19, "Black Clusterberry" }, { 20, "Red Clusterberry" }, { 21, "Yellow Clusterberry" }, { 22, "Green Clusterberry" }, { 23, "Compass" }, { 24, "Cure-All" }, { 25, "Cursed Skull" }, { 26, "Egg" }, { 27, "Energy Drink" }, { 28, "Stick" }, { 29, "First Aid Kit" }, { 30, "Seagull Flag" }, { 31, "Pink Berrynana Peel" }, { 32, "Flare" }, { 33, "Granola Bar" }, { 34, "Guidebook" }, { 35, "Heat Pack" }, { 36, "Coconut" }, { 37, "Balloon Bunch" }, { 38, "Honeycomb" }, { 39, "Cactus Ball" }, { 40, "Purple Kingberry" }, { 41, "Yellow Kingberry" }, { 42, "Lantern" }, { 43, "Faerie Lantern" }, { 44, "Lollipop" }, { 45, "Magic Bean" }, { 46, "Marshmallow" }, { 47, "Ancient Idol" }, { 48, "Basketball" }, { 49, "Scroll" }, { 50, "Torn Page 1" }, { 51, "Glowshroom" }, { 52, "Torn Page 3" }, { 53, "Torn Page 4" }, { 54, "Torn Page 8" }, { 55, "Coconut Half" }, { 56, "Green Kingberry" }, { 57, "Big Egg" }, { 58, "Pandoras Lunchbox" }, { 59, "Passport" }, { 60, "Scorchberry" }, { 61, "Pirates Compass" }, { 62, "Portable Stove" }, { 63, "Rope Cannon" }, { 64, "Anti-Rope Cannon" }, { 65, "Rope Spool" }, { 66, "Scout Cookies" }, { 67, "Scout Effigy" }, { 68, "Shelf Fungus" }, { 69, "Conch" }, { 70, "Blowgun" }, { 71, "Sports Drink" }, { 72, "Stone" }, { 73, "Trail Mix" }, { 74, "Warp Compass" }, { 75, "Orange Winterberry" }, { 76, "Yellow Winterberry" }, { 77, "Scoutmasters Bugle" }, { 78, "Megaphone" }, { 79, "Bounce Fungus" }, { 80, "Torn Page Blank" }, { 81, "Medicinal Root" }, { 82, "Torn Page 2" }, { 83, "Chubby Mushroom" }, { 84, "Poisonous Clustershroom" }, { 85, "Torn Page 5" }, { 86, "Torn Page 6" }, { 87, "Torn Page 7" }, { 88, "Clustershroom" }, { 89, "Poisonous Bugleshroom" }, { 90, "Remedy Fungus" }, { 91, "Blue Berrynana Peel" }, { 92, "Brown Berrynana Peel" }, { 93, "Bugleshroom" }, { 94, "Yellow Berrynana Peel" }, { 95, "Tick" }, { 96, "Torn Page 9" }, { 97, "Poisonous Buttonshroom" }, { 98, "Parasol" }, { 99, "Frisbee" }, { 100, "Rescue Hook" }, { 101, "Aloe Vera" }, { 102, "Buttonshroom" }, { 103, "Gold Prickleberry" }, { 104, "Sunscreen" }, { 105, "Balloon" }, { 106, "Dynamite" }, { 107, "Scout Cannon" }, { 108, "Red Prickleberry" }, { 109, "Torch" }, { 110, "Napberry" }, { 111, "Scorpion" }, { 112, "Strange Gem" }, { 113, "Cheat Compass" }, { 114, "Roasted Bird" }, { 115, "Bishop Black" }, { 116, "Bishop White" }, { 117, "King Black" }, { 118, "King White" }, { 119, "Knight Black" }, { 120, "Knight White" }, { 121, "Pawn Black" }, { 122, "Pawn White" }, { 123, "Queen Black" }, { 124, "Queen White" }, { 125, "Rook Black" }, { 126, "Rook White" }, { 127, "Turtle Flag" }, { 128, "BingBong Prop" }, { 129, "Binoculars Prop" }, { 130, "Bugle Prop" }, { 131, "Lollipop Prop" } }; private static readonly Dictionary<ushort, int> DefaultWeights = new Dictionary<ushort, int> { { 0, 0 }, { 1, 0 }, { 2, 0 }, { 3, 100 }, { 4, 100 }, { 5, 30 }, { 6, 0 }, { 7, 0 }, { 8, 0 }, { 9, 30 }, { 10, 30 }, { 11, 30 }, { 12, 100 }, { 13, 0 }, { 14, 0 }, { 15, 0 }, { 16, 0 }, { 17, 0 }, { 18, 0 }, { 19, 100 }, { 20, 100 }, { 21, 100 }, { 22, 0 }, { 23, 0 }, { 24, 0 }, { 25, 0 }, { 26, 0 }, { 27, 0 }, { 28, 0 }, { 29, 0 }, { 30, 0 }, { 31, 100 }, { 32, 0 }, { 33, 0 }, { 34, 0 }, { 35, 0 }, { 36, 100 }, { 37, 0 }, { 38, 0 }, { 39, 0 }, { 40, 50 }, { 41, 50 }, { 42, 0 }, { 43, 0 }, { 44, 0 }, { 45, 0 }, { 46, 0 }, { 47, 0 }, { 48, 0 }, { 49, 0 }, { 50, 0 }, { 51, 0 }, { 52, 0 }, { 53, 0 }, { 54, 0 }, { 55, 0 }, { 56, 100 }, { 57, 100 }, { 58, 0 }, { 59, 0 }, { 60, 50 }, { 61, 0 }, { 62, 0 }, { 63, 0 }, { 64, 0 }, { 65, 0 }, { 66, 0 }, { 67, 0 }, { 68, 100 }, { 69, 0 }, { 70, 0 }, { 71, 0 }, { 72, 0 }, { 73, 0 }, { 74, 0 }, { 75, 100 }, { 76, 1 }, { 77, 0 }, { 78, 0 }, { 79, 0 }, { 80, 0 }, { 81, 50 }, { 82, 0 }, { 83, 50 }, { 84, 30 }, { 85, 0 }, { 86, 0 }, { 87, 0 }, { 88, 50 }, { 89, 30 }, { 90, 0 }, { 91, 100 }, { 92, 100 }, { 93, 50 }, { 94, 100 }, { 95, 0 }, { 96, 0 }, { 97, 30 }, { 98, 0 }, { 99, 0 }, { 100, 0 }, { 101, 0 }, { 102, 50 }, { 103, 15 }, { 104, 0 }, { 105, 0 }, { 106, 0 }, { 107, 0 }, { 108, 100 }, { 109, 0 }, { 110, 0 }, { 111, 0 }, { 112, 0 }, { 113, 0 }, { 114, 0 }, { 115, 0 }, { 116, 0 }, { 117, 0 }, { 118, 0 }, { 119, 0 }, { 120, 0 }, { 121, 0 }, { 122, 0 }, { 123, 0 }, { 124, 0 }, { 125, 0 }, { 126, 0 }, { 127, 0 } }; private static readonly Dictionary<ushort, SpawnPool[]> DefaultPools = new Dictionary<ushort, SpawnPool[]> { { 0, (SpawnPool[])(object)new SpawnPool[0] }, { 1, (SpawnPool[])(object)new SpawnPool[0] }, { 2, (SpawnPool[])(object)new SpawnPool[0] }, { 3, (SpawnPool[])(object)new SpawnPool[2] { (SpawnPool)8, (SpawnPool)16 } }, { 4, (SpawnPool[])(object)new SpawnPool[2] { (SpawnPool)8, (SpawnPool)16 } }, { 5, (SpawnPool[])(object)new SpawnPool[2] { (SpawnPool)8, (SpawnPool)16 } }, { 6, (SpawnPool[])(object)new SpawnPool[0] }, { 7, (SpawnPool[])(object)new SpawnPool[0] }, { 8, (SpawnPool[])(object)new SpawnPool[0] }, { 9, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 10, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 11, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 12, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 13, (SpawnPool[])(object)new SpawnPool[0] }, { 14, (SpawnPool[])(object)new SpawnPool[0] }, { 15, (SpawnPool[])(object)new SpawnPool[0] }, { 16, (SpawnPool[])(object)new SpawnPool[0] }, { 17, (SpawnPool[])(object)new SpawnPool[0] }, { 18, (SpawnPool[])(object)new SpawnPool[0] }, { 19, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)32 } }, { 20, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)32 } }, { 21, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)32 } }, { 22, (SpawnPool[])(object)new SpawnPool[0] }, { 23, (SpawnPool[])(object)new SpawnPool[0] }, { 24, (SpawnPool[])(object)new SpawnPool[0] }, { 25, (SpawnPool[])(object)new SpawnPool[0] }, { 26, (SpawnPool[])(object)new SpawnPool[0] }, { 27, (SpawnPool[])(object)new SpawnPool[0] }, { 28, (SpawnPool[])(object)new SpawnPool[0] }, { 29, (SpawnPool[])(object)new SpawnPool[0] }, { 30, (SpawnPool[])(object)new SpawnPool[0] }, { 31, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 32, (SpawnPool[])(object)new SpawnPool[0] }, { 33, (SpawnPool[])(object)new SpawnPool[0] }, { 34, (SpawnPool[])(object)new SpawnPool[0] }, { 35, (SpawnPool[])(object)new SpawnPool[0] }, { 36, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)64 } }, { 37, (SpawnPool[])(object)new SpawnPool[0] }, { 38, (SpawnPool[])(object)new SpawnPool[0] }, { 39, (SpawnPool[])(object)new SpawnPool[0] }, { 40, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 41, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 42, (SpawnPool[])(object)new SpawnPool[0] }, { 43, (SpawnPool[])(object)new SpawnPool[0] }, { 44, (SpawnPool[])(object)new SpawnPool[0] }, { 45, (SpawnPool[])(object)new SpawnPool[0] }, { 46, (SpawnPool[])(object)new SpawnPool[0] }, { 47, (SpawnPool[])(object)new SpawnPool[0] }, { 48, (SpawnPool[])(object)new SpawnPool[0] }, { 49, (SpawnPool[])(object)new SpawnPool[0] }, { 50, (SpawnPool[])(object)new SpawnPool[0] }, { 51, (SpawnPool[])(object)new SpawnPool[0] }, { 52, (SpawnPool[])(object)new SpawnPool[0] }, { 53, (SpawnPool[])(object)new SpawnPool[0] }, { 54, (SpawnPool[])(object)new SpawnPool[0] }, { 55, (SpawnPool[])(object)new SpawnPool[0] }, { 56, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 57, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)262144 } }, { 58, (SpawnPool[])(object)new SpawnPool[0] }, { 59, (SpawnPool[])(object)new SpawnPool[0] }, { 60, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)16 } }, { 61, (SpawnPool[])(object)new SpawnPool[0] }, { 62, (SpawnPool[])(object)new SpawnPool[0] }, { 63, (SpawnPool[])(object)new SpawnPool[0] }, { 64, (SpawnPool[])(object)new SpawnPool[0] }, { 65, (SpawnPool[])(object)new SpawnPool[0] }, { 66, (SpawnPool[])(object)new SpawnPool[0] }, { 67, (SpawnPool[])(object)new SpawnPool[0] }, { 68, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)8388608 } }, { 69, (SpawnPool[])(object)new SpawnPool[0] }, { 70, (SpawnPool[])(object)new SpawnPool[0] }, { 71, (SpawnPool[])(object)new SpawnPool[0] }, { 72, (SpawnPool[])(object)new SpawnPool[0] }, { 73, (SpawnPool[])(object)new SpawnPool[0] }, { 74, (SpawnPool[])(object)new SpawnPool[0] }, { 75, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)512 } }, { 76, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)512 } }, { 77, (SpawnPool[])(object)new SpawnPool[0] }, { 78, (SpawnPool[])(object)new SpawnPool[0] }, { 79, (SpawnPool[])(object)new SpawnPool[0] }, { 80, (SpawnPool[])(object)new SpawnPool[0] }, { 81, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 82, (SpawnPool[])(object)new SpawnPool[0] }, { 83, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 84, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 85, (SpawnPool[])(object)new SpawnPool[0] }, { 86, (SpawnPool[])(object)new SpawnPool[0] }, { 87, (SpawnPool[])(object)new SpawnPool[0] }, { 88, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 89, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 90, (SpawnPool[])(object)new SpawnPool[0] }, { 91, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 92, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 93, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 94, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 95, (SpawnPool[])(object)new SpawnPool[0] }, { 96, (SpawnPool[])(object)new SpawnPool[0] }, { 97, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 98, (SpawnPool[])(object)new SpawnPool[0] }, { 99, (SpawnPool[])(object)new SpawnPool[0] }, { 100, (SpawnPool[])(object)new SpawnPool[0] }, { 101, (SpawnPool[])(object)new SpawnPool[0] }, { 102, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 103, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4194304 } }, { 104, (SpawnPool[])(object)new SpawnPool[0] }, { 105, (SpawnPool[])(object)new SpawnPool[0] }, { 106, (SpawnPool[])(object)new SpawnPool[0] }, { 107, (SpawnPool[])(object)new SpawnPool[0] }, { 108, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4194304 } }, { 109, (SpawnPool[])(object)new SpawnPool[0] }, { 110, (SpawnPool[])(object)new SpawnPool[0] }, { 111, (SpawnPool[])(object)new SpawnPool[0] }, { 112, (SpawnPool[])(object)new SpawnPool[0] }, { 113, (SpawnPool[])(object)new SpawnPool[0] }, { 114, (SpawnPool[])(object)new SpawnPool[0] }, { 115, (SpawnPool[])(object)new SpawnPool[0] }, { 116, (SpawnPool[])(object)new SpawnPool[0] }, { 117, (SpawnPool[])(object)new SpawnPool[0] }, { 118, (SpawnPool[])(object)new SpawnPool[0] }, { 119, (SpawnPool[])(object)new SpawnPool[0] }, { 120, (SpawnPool[])(object)new SpawnPool[0] }, { 121, (SpawnPool[])(object)new SpawnPool[0] }, { 122, (SpawnPool[])(object)new SpawnPool[0] }, { 123, (SpawnPool[])(object)new SpawnPool[0] }, { 124, (SpawnPool[])(object)new SpawnPool[0] }, { 125, (SpawnPool[])(object)new SpawnPool[0] }, { 126, (SpawnPool[])(object)new SpawnPool[0] }, { 127, (SpawnPool[])(object)new SpawnPool[0] } }; private void DetectAndLoadModItems() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Detecting installed mods for automatic item integration..."); List<ModItemInfo> list = new List<ModItemInfo>(); List<ModItemInfo> list2 = new List<ModItemInfo>(); foreach (KeyValuePair<string, List<ModItemInfo>> detectedMod in DetectedMods) { string key = detectedMod.Key; List<ModItemInfo> value = detectedMod.Value; bool flag = ModLoadedStatus.ContainsKey(key) && ModLoadedStatus[key]; bool flag2 = CheckMod(key); ModLoadedStatus[key] = flag2; if (flag2) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Mod detected: {key} - Adding {value.Count} items to configuration"); foreach (ModItemInfo item in value) { list2.Add(item); LogDetailed($" - Processing {item.ItemName} (ID: {item.ItemID}, Weight: {item.DefaultWeight})"); if (!ItemNames.ContainsKey(item.ItemID)) { ItemNames[item.ItemID] = item.ItemName; LogDetailed(" - Added to ItemNames"); } if (!DefaultWeights.ContainsKey(item.ItemID)) { DefaultWeights[item.ItemID] = item.DefaultWeight; LogDetailed(" - Added to DefaultWeights"); } if (!DefaultPools.ContainsKey(item.ItemID)) { DefaultPools[item.ItemID] = item.DefaultPools; LogDetailed(" - Added to DefaultPools"); } } continue; } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Mod not detected: {key} - Will remove {value.Count} items from configuration"); foreach (ModItemInfo item2 in value) { list.Add(item2); LogDetailed($" - Will remove {item2.ItemName} (ID: {item2.ItemID})"); } } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Setting up configuration entries for detected mod items..."); SetupConfigs(); if (list.Count > 0) { CleanConfigFile(list); } } private void CleanConfigFile(List<ModItemInfo> undetectedMods) { try { string configFilePath = config.ConfigFilePath; string text = configFilePath.Replace(".cfg", "_backup.cfg"); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Cleaning config file of {undetectedMods.Count} undetected mod items..."); LogDetailed("Config path: " + configFilePath); LogDetailed("Backup path: " + text); if (File.Exists(configFilePath)) { File.Copy(configFilePath, text, overwrite: true); LogDetailed("Backup created successfully"); List<string> list = File.ReadAllLines(text).ToList(); List<string> list2 = new List<string>(); HashSet<string> hashSet = undetectedMods.Select((ModItemInfo m) => SanitizeConfigKey(m.ItemName)).ToHashSet(); LogDetailed("Items to remove (sanitized): " + string.Join(", ", hashSet)); bool flag = false; int num = 0; foreach (string item2 in list) { if (item2.Contains("## Spawn weight for ") || item2.Contains("## Spawn pools for ")) { Match match = Regex.Match(item2, "## Spawn (weight|pools) for ([^(]+)"); if (match.Success) { string text2 = match.Groups[2].Value.Trim(); string item = SanitizeConfigKey(text2); flag = hashSet.Contains(item); if (flag) { LogDetailed("Removing config entries for: " + text2); num++; continue; } } } else if (item2.Contains(" Weight =") || item2.Contains(" Pools =")) { foreach (string item3 in hashSet) { if (item2.Contains(item3 + " Weight =") || item2.Contains(item3 + " Pools =")) { LogDetailed("Removing direct config entry: " + item2.Trim()); num++; flag = true; break; } } if (flag) { continue; } } if (flag) { if (string.IsNullOrWhiteSpace(item2) || item2.StartsWith("[") || item2.StartsWith("##")) { flag = false; } } else { list2.Add(item2); } } LogDetailed($"Removed {num} item sections from config"); File.WriteAllLines(configFilePath, list2); LogDetailed("Cleaned config written to file"); foreach (ModItemInfo undetectedMod in undetectedMods) { ItemNames.Remove(undetectedMod.ItemID); DefaultWeights.Remove(undetectedMod.ItemID); DefaultPools.Remove(undetectedMod.ItemID); LogDetailed($"Removed {undetectedMod.ItemName} (ID: {undetectedMod.ItemID}) from dictionaries"); } if (File.Exists(text)) { File.Delete(text); LogDetailed("Backup file deleted: " + text); } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Config file cleaned successfully. Removed {undetectedMods.Count} undetected mod items."); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Config file does not exist, nothing to clean"); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to clean config file: " + ex.Message)); ((BaseUnityPlugin)this).Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } } private bool CheckMod(string modGUID) { try { return Chainloader.PluginInfos.ContainsKey(modGUID); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error checking mod " + modGUID + ": " + ex.Message)); return false; } } private string SanitizeConfigKey(string name) { return name.Replace("'", "").Replace("\"", "").Replace("=", "") .Replace("\n", "") .Replace("\t", "") .Replace("\\", "") .Replace("[", "") .Replace("]", ""); } private void LogDetailed(string message) { if (enableDetailedLogging != null && enableDetailedLogging.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } } private void LogDetailedWarning(string message) { if (enableDetailedLogging != null && enableDetailedLogging.Value) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } } private void LogDetailedError(string message) { if (enableDetailedLogging != null && enableDetailedLogging.Value) { ((BaseUnityPlugin)this).Logger.LogError((object)message); } } private void Awake() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown config = ((BaseUnityPlugin)this).Config; enableDetailedLogging = config.Bind<bool>("Settings", "Enable Detailed Logging", false, "Enable detailed logging for debugging purposes. When disabled, only essential messages are logged."); Harmony val = new Harmony("tony4twentys.PEAK_Nature_Items"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin tony4twentys.PEAK_Nature_Items is loaded!"); } private void Start() { DetectAndLoadModItems(); } private void SetupConfigs() { LogDetailed("Starting SetupConfigs..."); List<KeyValuePair<ushort, string>> list = ItemNames.OrderBy((KeyValuePair<ushort, string> x) => x.Value).ToList(); foreach (KeyValuePair<ushort, string> item in list) { ushort id = item.Key; string value = item.Value; int num = (DefaultWeights.ContainsKey(id) ? DefaultWeights[id] : 0); SpawnPool[] source; if (DefaultPools.ContainsKey(id)) { source = DefaultPools[id]; } else { SpawnPool[] array = new SpawnPool[11]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); source = (SpawnPool[])(object)array; } string text = "Item Weights"; string text2 = "Item Spawn Pools"; if (DetectedMods.Values.Any((List<ModItemInfo> itemList) => itemList.Any((ModItemInfo mod) => mod.ItemID == id))) { text = "Detected Mods Item Weights"; text2 = "Detected Mods Item Spawn Pools"; } string text3 = SanitizeConfigKey(value); try { itemWeights[id] = config.Bind<int>(text, text3 + " Weight", num, "Spawn weight for " + value + " (0 = disabled)"); LogDetailed(" - Bound weight for " + value); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to bind weight for " + value + ": " + ex.Message)); } string text4 = string.Join(",", source.Select((SpawnPool p) => ((object)(SpawnPool)(ref p)).ToString())); try { itemPools[id] = config.Bind<string>(text2, text3 + " Pools", text4, "Spawn pools for " + value + " (comma-separated: MushroomCluster, BerryBushBeach, etc.)"); LogDetailed(" - Bound pools for " + value); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to bind pools for " + value + ": " + ex2.Message)); } } } private static void OverrideItemWeights() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) if (LootData.AllSpawnWeightData == null) { return; } SpawnPool[] array = new SpawnPool[11]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); SpawnPool[] array2 = (SpawnPool[])(object)array; foreach (KeyValuePair<ushort, string> itemName in ItemNames) { ushort key = itemName.Key; string value = itemName.Value; if (!itemWeights.ContainsKey(key) || !itemPools.ContainsKey(key)) { continue; } int value2 = itemWeights[key].Value; string value3 = itemPools[key].Value; SpawnPool[] array3 = array2; foreach (SpawnPool key2 in array3) { if (LootData.AllSpawnWeightData.ContainsKey(key2) && LootData.AllSpawnWeightData[key2].ContainsKey(key)) { LootData.AllSpawnWeightData[key2].Remove(key); } } if (value2 == 0) { continue; } List<SpawnPool> list = new List<SpawnPool>(); if (!string.IsNullOrEmpty(value3)) { string[] array4 = value3.Split(new char[1] { ',' }); string[] array5 = array4; foreach (string text in array5) { if (Enum.TryParse<SpawnPool>(text.Trim(), out SpawnPool result)) { list.Add(result); } } } foreach (SpawnPool item in list) { if (LootData.AllSpawnWeightData.ContainsKey(item) && array2.Contains(item)) { LootData.AllSpawnWeightData[item][key] = value2; } } } } }