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 StonePick v1.1.1
plugins/StonePickMod.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Jotunn.Entities; using Jotunn.Managers; 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("StonePickMod")] [assembly: AssemblyDescription("A blazing hot sword forged from fire and steel. Its flames burn through the living, leaving only ash behind...")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("proflupin")] [assembly: AssemblyProduct("StonePickMod")] [assembly: AssemblyCopyright("Copyright © proflupin 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7e61f470-fb41-4c6b-a654-4e199ea7d009")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] namespace StonePickMod; [BepInPlugin("proflupin.stonepickmod", "StonePickMod", "1.0.0")] public class StonePickMod : BaseUnityPlugin { public const string PluginGUID = "proflupin.stonepickmod"; public const string PluginName = "StonePickMod"; public const string PluginVersion = "1.0.0"; private ConfigEntry<int> cfg_woodAmount; private ConfigEntry<int> cfg_stoneAmount; private ConfigEntry<int> cfg_minStationLevel; private ConfigEntry<float> cfg_pickaxeDamage; private ConfigEntry<int> cfg_toolTier; private ConfigEntry<int> cfg_maxQuality; private ConfigEntry<int> cfg_itemQuality; private ConfigEntry<string> cfg_ingredients; [Obsolete] private void Awake() { cfg_woodAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "WoodAmount", 8, "Amount of Wood required for Stone Pick"); cfg_stoneAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "StoneAmount", 15, "Amount of Stone required for Stone Pick"); cfg_minStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "MinStationLevel", 0, "Required Workbench level for crafting (0 = none)"); cfg_ingredients = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "Ingredients", "Wood:8,Stone:15", "Comma-separated list of ingredients in the format Name:Amount. e.g. Wood:8,Stone:15"); cfg_pickaxeDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Item", "PickaxeDamage", 20f, "Pickaxe damage value"); cfg_toolTier = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "ToolTier", 1, "Tool tier (what ores it can mine)"); cfg_maxQuality = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "MaxQuality", 1, "Max quality for the item"); cfg_itemQuality = ((BaseUnityPlugin)this).Config.Bind<int>("Item", "DefaultQuality", 1, "Default quality for the crafted item"); PrefabManager.OnVanillaPrefabsAvailable += AddCustomWeapon; LocalizationManager.OnLocalizationAdded += AddLocalization; } private Requirement[] CreateRequirementsFromConfig(string cfg) { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown if (string.IsNullOrWhiteSpace(cfg)) { return null; } try { List<Requirement> list = new List<Requirement>(); string[] array = cfg.Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[2] { ':', '=' }, StringSplitOptions.RemoveEmptyEntries); if (array3.Length < 2) { continue; } string text2 = array3[0].Trim(); string text3 = array3[1].Trim(); if (!int.TryParse(text3, out var result)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid amount for ingredient '" + text2 + "' in config: '" + text3 + "'")); continue; } GameObject prefab = PrefabManager.Instance.GetPrefab(text2); ItemDrop val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find prefab or ItemDrop for ingredient '" + text2 + "' (skipping)")); continue; } list.Add(new Requirement { m_resItem = val, m_amount = result, m_recover = true }); } return list.ToArray(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Error parsing recipe ingredients from config: " + ex.Message)); return null; } } [Obsolete] private void AddLocalization() { LocalizationManager.Instance.AddToken("item_pick_stone", "Stone Pick", false); LocalizationManager.Instance.AddToken("item_pick_stone_desc", "A crude and flimsy pick made of stone roughly bound to a stick.", false); } private void AddCustomWeapon() { //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown string[] array = new string[3] { "PickaxeStone", "Pickaxe", "PickaxeIron" }; GameObject val = null; string text = null; string[] array2 = array; foreach (string text2 in array2) { val = PrefabManager.Instance.GetPrefab(text2); if ((Object)(object)val != (Object)null) { text = text2; break; } } if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find any base prefab for pickaxe (tried PickaxeStone, Pickaxe, PickaxeIron)!"); return; } GameObject val2 = Object.Instantiate<GameObject>(val); ((Object)val2).name = "PickStone"; ItemDrop component = val2.GetComponent<ItemDrop>(); if ((Object)(object)component == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Cloned prefab does not contain ItemDrop component!"); return; } component.m_itemData.m_shared.m_name = "$item_pick_stone"; component.m_itemData.m_shared.m_description = "$item_pick_stone_desc"; component.m_itemData.m_shared.m_damages.m_pickaxe = cfg_pickaxeDamage.Value; component.m_itemData.m_shared.m_maxQuality = cfg_maxQuality.Value; component.m_itemData.m_shared.m_toolTier = cfg_toolTier.Value; component.m_itemData.m_quality = cfg_itemQuality.Value; CustomItem val3 = new CustomItem(val2, true); ItemManager.Instance.AddItem(val3); AddRecipe(val3.ItemDrop); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[StonePickMod] succesfully loaded."); } private void AddRecipe(ItemDrop item) { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown if ((Object)(object)item == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"AddRecipe called with null ItemDrop!"); return; } Requirement[] array = CreateRequirementsFromConfig(cfg_ingredients.Value); if (array == null || array.Length == 0) { GameObject prefab = PrefabManager.Instance.GetPrefab("Wood"); ItemDrop val = ((prefab != null) ? prefab.GetComponent<ItemDrop>() : null); GameObject prefab2 = PrefabManager.Instance.GetPrefab("Stone"); ItemDrop val2 = ((prefab2 != null) ? prefab2.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find Wood or Stone prefab for fallback recipe!"); return; } array = (Requirement[])(object)new Requirement[2] { new Requirement { m_resItem = val, m_amount = cfg_woodAmount.Value, m_recover = true }, new Requirement { m_resItem = val2, m_amount = cfg_stoneAmount.Value, m_recover = true } }; } GameObject prefab3 = PrefabManager.Instance.GetPrefab("WorkBench"); if ((Object)(object)prefab3 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Could not find WorkBench prefab for recipe!"); return; } CraftingStation component = prefab3.GetComponent<CraftingStation>(); if ((Object)(object)component == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"WorkBench prefab does not have CraftingStation component!"); return; } Recipe val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_PickStone"; val3.m_item = item; val3.m_amount = 1; val3.m_enabled = true; val3.m_minStationLevel = cfg_minStationLevel.Value; val3.m_resources = array; val3.m_craftingStation = component; CustomRecipe val4 = new CustomRecipe(val3, true, true); ItemManager.Instance.AddRecipe(val4); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Recipe for 'PickStone' successfully added."); } }