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.1.0
tony4twentys-PEAK Nature Items.dll
Decompiled 4 days 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.Text; using BepInEx; 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: AssemblyVersion("1.0.0.0")] namespace PEAKNatureItems; public class CustomItem { public ushort itemID { get; set; } public int itemWeight { get; set; } public string spawnPools { get; set; } } public class CustomItemsConfig { public List<CustomItem> customItems { get; set; } = new List<CustomItem>(); } [BepInPlugin("tony4twentys.PEAK_Nature_Items", "PEAK Nature Items", "1.0.0")] 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 ConfigEntry<bool> enableCustomItems; 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 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, "Turtle Flag" }, { 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" }, { 114, "Roasted Chicken" } }; 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, 100 }, { 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 }, { 114, 0 } }; private static readonly Dictionary<ushort, SpawnPool[]> DefaultPools = new Dictionary<ushort, SpawnPool[]> { { 0, (SpawnPool[])(object)new SpawnPool[1] }, { 1, (SpawnPool[])(object)new SpawnPool[1] }, { 2, (SpawnPool[])(object)new SpawnPool[1] }, { 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[1] }, { 7, (SpawnPool[])(object)new SpawnPool[1] }, { 8, (SpawnPool[])(object)new SpawnPool[1] }, { 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[1] }, { 14, (SpawnPool[])(object)new SpawnPool[1] }, { 15, (SpawnPool[])(object)new SpawnPool[1] }, { 16, (SpawnPool[])(object)new SpawnPool[1] }, { 17, (SpawnPool[])(object)new SpawnPool[1] }, { 18, (SpawnPool[])(object)new SpawnPool[1] }, { 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[1] }, { 23, (SpawnPool[])(object)new SpawnPool[1] }, { 24, (SpawnPool[])(object)new SpawnPool[1] }, { 25, (SpawnPool[])(object)new SpawnPool[1] }, { 26, (SpawnPool[])(object)new SpawnPool[1] }, { 27, (SpawnPool[])(object)new SpawnPool[1] }, { 28, (SpawnPool[])(object)new SpawnPool[1] }, { 29, (SpawnPool[])(object)new SpawnPool[1] }, { 30, (SpawnPool[])(object)new SpawnPool[1] }, { 31, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 32, (SpawnPool[])(object)new SpawnPool[1] }, { 33, (SpawnPool[])(object)new SpawnPool[1] }, { 34, (SpawnPool[])(object)new SpawnPool[1] }, { 35, (SpawnPool[])(object)new SpawnPool[1] }, { 36, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)64 } }, { 37, (SpawnPool[])(object)new SpawnPool[1] }, { 38, (SpawnPool[])(object)new SpawnPool[1] }, { 39, (SpawnPool[])(object)new SpawnPool[1] }, { 40, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 41, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 42, (SpawnPool[])(object)new SpawnPool[1] }, { 43, (SpawnPool[])(object)new SpawnPool[1] }, { 44, (SpawnPool[])(object)new SpawnPool[1] }, { 45, (SpawnPool[])(object)new SpawnPool[1] }, { 46, (SpawnPool[])(object)new SpawnPool[1] }, { 47, (SpawnPool[])(object)new SpawnPool[1] }, { 48, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)256 } }, { 49, (SpawnPool[])(object)new SpawnPool[1] }, { 50, (SpawnPool[])(object)new SpawnPool[1] }, { 51, (SpawnPool[])(object)new SpawnPool[1] }, { 52, (SpawnPool[])(object)new SpawnPool[1] }, { 53, (SpawnPool[])(object)new SpawnPool[1] }, { 54, (SpawnPool[])(object)new SpawnPool[1] }, { 55, (SpawnPool[])(object)new SpawnPool[1] }, { 56, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)128 } }, { 57, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)262144 } }, { 58, (SpawnPool[])(object)new SpawnPool[1] }, { 59, (SpawnPool[])(object)new SpawnPool[1] }, { 60, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)16 } }, { 61, (SpawnPool[])(object)new SpawnPool[1] }, { 62, (SpawnPool[])(object)new SpawnPool[1] }, { 63, (SpawnPool[])(object)new SpawnPool[1] }, { 64, (SpawnPool[])(object)new SpawnPool[1] }, { 65, (SpawnPool[])(object)new SpawnPool[1] }, { 66, (SpawnPool[])(object)new SpawnPool[1] }, { 67, (SpawnPool[])(object)new SpawnPool[1] }, { 68, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)8388608 } }, { 69, (SpawnPool[])(object)new SpawnPool[1] }, { 70, (SpawnPool[])(object)new SpawnPool[1] }, { 71, (SpawnPool[])(object)new SpawnPool[1] }, { 72, (SpawnPool[])(object)new SpawnPool[1] }, { 73, (SpawnPool[])(object)new SpawnPool[1] }, { 74, (SpawnPool[])(object)new SpawnPool[1] }, { 75, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)512 } }, { 76, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)512 } }, { 77, (SpawnPool[])(object)new SpawnPool[1] }, { 78, (SpawnPool[])(object)new SpawnPool[1] }, { 79, (SpawnPool[])(object)new SpawnPool[1] }, { 80, (SpawnPool[])(object)new SpawnPool[1] }, { 81, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 82, (SpawnPool[])(object)new SpawnPool[1] }, { 83, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 84, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 85, (SpawnPool[])(object)new SpawnPool[1] }, { 86, (SpawnPool[])(object)new SpawnPool[1] }, { 87, (SpawnPool[])(object)new SpawnPool[1] }, { 88, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 89, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 90, (SpawnPool[])(object)new SpawnPool[1] }, { 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[1] }, { 96, (SpawnPool[])(object)new SpawnPool[1] }, { 97, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 98, (SpawnPool[])(object)new SpawnPool[1] }, { 99, (SpawnPool[])(object)new SpawnPool[1] }, { 100, (SpawnPool[])(object)new SpawnPool[1] }, { 101, (SpawnPool[])(object)new SpawnPool[1] }, { 102, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4 } }, { 103, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4194304 } }, { 104, (SpawnPool[])(object)new SpawnPool[1] }, { 105, (SpawnPool[])(object)new SpawnPool[1] }, { 106, (SpawnPool[])(object)new SpawnPool[1] }, { 107, (SpawnPool[])(object)new SpawnPool[1] }, { 108, (SpawnPool[])(object)new SpawnPool[1] { (SpawnPool)4194304 } }, { 109, (SpawnPool[])(object)new SpawnPool[1] }, { 110, (SpawnPool[])(object)new SpawnPool[1] }, { 111, (SpawnPool[])(object)new SpawnPool[1] }, { 112, (SpawnPool[])(object)new SpawnPool[1] }, { 114, (SpawnPool[])(object)new SpawnPool[1] } }; private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown config = ((BaseUnityPlugin)this).Config; LoadCustomItems(); SetupConfigs(); Harmony val = new Harmony("tony4twentys.PEAK_Nature_Items"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin tony4twentys.PEAK_Nature_Items is loaded!"); } private void LoadCustomItems() { //IL_0145: Unknown result type (might be due to invalid IL or missing references) try { string text = Path.Combine(Paths.ConfigPath, "PEAK_Nature_Items_Custom.json"); if (!File.Exists(text)) { CreateExampleCustomItemsFile(text); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Created example custom items file at: " + text)); return; } string jsonContent = File.ReadAllText(text); CustomItemsConfig customItemsConfig = ParseCustomItemsJson(jsonContent); if (customItemsConfig?.customItems == null) { return; } foreach (CustomItem customItem in customItemsConfig.customItems) { if (!ItemNames.ContainsKey(customItem.itemID)) { ItemNames[customItem.itemID] = $"Custom Item {customItem.itemID}"; } DefaultWeights[customItem.itemID] = customItem.itemWeight; List<SpawnPool> list = new List<SpawnPool>(); if (!string.IsNullOrEmpty(customItem.spawnPools)) { string[] array = customItem.spawnPools.Split(new char[1] { ',' }); string[] array2 = array; foreach (string text2 in array2) { if (Enum.TryParse<SpawnPool>(text2.Trim(), out SpawnPool result)) { list.Add(result); } } } if (list.Count > 0) { DefaultPools[customItem.itemID] = list.ToArray(); } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loaded custom item: ID {customItem.itemID}, Weight {customItem.itemWeight}, Pools {customItem.spawnPools}"); } } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Error loading custom items: {arg}"); } } private void CreateExampleCustomItemsFile(string filePath) { CustomItemsConfig customItemsConfig = new CustomItemsConfig { customItems = new List<CustomItem> { new CustomItem { itemID = 33466, itemWeight = 15, spawnPools = "SpawnPool.MushroomCluster, SpawnPool.BerryBushBeach, SpawnPool.BerryBushJungle, SpawnPool.SpikyVine, SpawnPool.CoconutTree, SpawnPool.WillowTreeJungle, SpawnPool.JungleVine, SpawnPool.WinterberryTree, SpawnPool.Nest, SpawnPool.Cactus, SpawnPool.Redwood" } } }; string text = SerializeCustomItemsToJson(customItemsConfig); string text2 = "// PEAK Nature Items - Custom Items Configuration\r\n// \r\n// This file allows you to add custom items from other mods to natural spawn locations.\r\n// \r\n// Example item (ID 33466) is from the Glizzy Mod - replace it if you dont have this mod installed.\r\n// To add your own items:\r\n// 1. Find the item ID from the mod you want to add\r\n// 2. Set itemWeight to desired spawn weight (0 = disabled)\r\n// 3. Set spawnPools to desired natural locations (comma-separated)\r\n// 4. Make sure 'Enable Custom Items' is set to true in the main config\r\n//\r\n// Available spawn pools: SpawnPool.MushroomCluster, SpawnPool.BerryBushBeach, SpawnPool.BerryBushJungle, SpawnPool.SpikyVine, \r\n// SpawnPool.CoconutTree, SpawnPool.WillowTreeJungle, SpawnPool.JungleVine, SpawnPool.WinterberryTree, SpawnPool.Nest, SpawnPool.Cactus, SpawnPool.Redwood\r\n//\r\n"; File.WriteAllText(filePath, text2 + text); } private CustomItemsConfig ParseCustomItemsJson(string jsonContent) { try { CustomItemsConfig customItemsConfig = new CustomItemsConfig(); string[] array = jsonContent.Split(new char[1] { '\n' }); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (!text.Contains("\"itemID\"")) { continue; } CustomItem customItem = new CustomItem(); int num = text.IndexOf(':') + 1; int num2 = text.IndexOf(',', num); if (num2 == -1) { num2 = text.Length; } string s = text.Substring(num, num2 - num).Trim().TrimEnd(new char[1] { ',' }); if (ushort.TryParse(s, out var result)) { customItem.itemID = result; } if (i + 1 < array.Length) { string text2 = array[i + 1].Trim(); if (text2.Contains("\"itemWeight\"")) { int num3 = text2.IndexOf(':') + 1; int num4 = text2.IndexOf(',', num3); if (num4 == -1) { num4 = text2.Length; } string s2 = text2.Substring(num3, num4 - num3).Trim().TrimEnd(new char[1] { ',' }); if (int.TryParse(s2, out var result2)) { customItem.itemWeight = result2; } } } if (i + 2 < array.Length) { string text3 = array[i + 2].Trim(); if (text3.Contains("\"spawnPools\"")) { int num5 = text3.IndexOf(':') + 1; int num6 = text3.IndexOf(',', num5); if (num6 == -1) { num6 = text3.Length; } string text4 = text3.Substring(num5, num6 - num5).Trim().TrimEnd(new char[1] { ',' }); customItem.spawnPools = text4.Trim(new char[1] { '"' }); } } customItemsConfig.customItems.Add(customItem); } return customItemsConfig; } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Error parsing custom items JSON: {arg}"); return new CustomItemsConfig(); } } private string SerializeCustomItemsToJson(CustomItemsConfig config) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("{"); stringBuilder.AppendLine(" \"customItems\": ["); for (int i = 0; i < config.customItems.Count; i++) { CustomItem customItem = config.customItems[i]; stringBuilder.AppendLine(" {"); stringBuilder.AppendLine($" \"itemID\": {customItem.itemID},"); stringBuilder.AppendLine($" \"itemWeight\": {customItem.itemWeight},"); stringBuilder.AppendLine(" \"spawnPools\": \"" + customItem.spawnPools + "\""); stringBuilder.Append((i == config.customItems.Count - 1) ? " }" : " },"); stringBuilder.AppendLine(); } stringBuilder.AppendLine(" ]"); stringBuilder.AppendLine("}"); return stringBuilder.ToString(); } private void SetupConfigs() { enableCustomItems = config.Bind<bool>("General", "Enable Custom Items", false, "Enable loading custom items from PEAK_Nature_Items_Custom.json file. Set to false if you don't have the required mods installed."); List<KeyValuePair<ushort, string>> list = ItemNames.OrderBy((KeyValuePair<ushort, string> x) => x.Value).ToList(); foreach (KeyValuePair<ushort, string> item in list) { ushort key = item.Key; string value = item.Value; int num = (DefaultWeights.ContainsKey(key) ? DefaultWeights[key] : 0); SpawnPool[] source; if (DefaultPools.ContainsKey(key)) { source = DefaultPools[key]; } else { SpawnPool[] array = new SpawnPool[11]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); source = (SpawnPool[])(object)array; } itemWeights[key] = config.Bind<int>("Item Weights", value + " Weight", num, "Spawn weight for " + value + " in natural locations (0 = disabled)"); string text = string.Join(",", source.Select((SpawnPool p) => ((object)(SpawnPool)(ref p)).ToString())); itemPools[key] = config.Bind<string>("Item Spawn Pools", value + " Pools", text, "Natural spawn pools for " + value + " (comma-separated: MushroomCluster, BerryBushBeach, etc.)"); } } private static void OverrideItemWeights() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) if (LootData.AllSpawnWeightData == null) { return; } ConfigEntry<bool> obj = enableCustomItems; if (obj == null || !obj.Value) { Debug.Log((object)"[PEAK Nature Items] Custom items processing is disabled in config. Set 'Enable Custom Items' to true to process custom items."); } 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; } if (value.StartsWith("Custom Item")) { ConfigEntry<bool> obj2 = enableCustomItems; if (obj2 == null || !obj2.Value) { 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; } } } } }