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 DisableHellbroth v1.0.0
Cjayride.DisableHellbroth.dll
Decompiled a day agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.DisableHellbroth")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Cjayride.DisableHellbroth")] [assembly: AssemblyTitle("Cjayride.DisableHellbroth")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Cjayride.DisableHellbroth { [BepInPlugin("cjayride.DisableHellbroth", "Disable Hellbroth", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "cjayride.DisableHellbroth"; public const string PluginName = "Disable Hellbroth"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; new Harmony("cjayride.DisableHellbroth").PatchAll(); GameObject val = new GameObject("Cjayride.DisableHellbroth.Purge"); Object.DontDestroyOnLoad((Object)val); val.AddComponent<DelayedRecipePurge>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Hellbroth potions: recipes purged and craft/use blocked (PotionsPlus Disabled bypass fix)."); } } internal static class HellbrothIds { internal static bool IsHellbroth(string name) { if (!string.IsNullOrEmpty(name)) { return name.IndexOf("Hellbroth", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } internal static bool IsHellbroth(ItemData item) { if (item?.m_shared == null) { return false; } if ((Object)(object)item.m_dropPrefab != (Object)null && IsHellbroth(((Object)item.m_dropPrefab).name)) { return true; } return IsHellbroth(item.m_shared.m_name); } internal static bool IsHellbroth(Recipe recipe) { if ((Object)(object)recipe?.m_item != (Object)null) { return IsHellbroth(recipe.m_item.m_itemData); } return false; } } internal static class HellbrothRecipePurge { internal static void PurgeObjectDb(ObjectDB db) { if (db?.m_recipes == null) { return; } int num = db.m_recipes.RemoveAll(HellbrothIds.IsHellbroth); if (num > 0) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogInfo((object)$"Removed {num} Hellbroth recipe(s) from ObjectDB."); } } } } internal sealed class DelayedRecipePurge : MonoBehaviour { private void Start() { ((MonoBehaviour)this).StartCoroutine(PurgeRepeatedly()); } private static IEnumerator PurgeRepeatedly() { float[] delays = new float[5] { 0.5f, 2f, 5f, 15f, 30f }; for (int i = 0; i < delays.Length; i++) { yield return (object)new WaitForSeconds(delays[i]); if ((Object)(object)ObjectDB.instance != (Object)null) { HellbrothRecipePurge.PurgeObjectDb(ObjectDB.instance); } } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] internal static class ObjectDbAwakePurgeHellbroth { private static void Postfix(ObjectDB __instance) { HellbrothRecipePurge.PurgeObjectDb(__instance); } } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] internal static class ObjectDbCopyPurgeHellbroth { private static void Postfix(ObjectDB __instance) { HellbrothRecipePurge.PurgeObjectDb(__instance); } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] internal static class BlockHellbrothCrafting { private static readonly FieldInfo CraftRecipeField = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe"); private static bool Prefix(InventoryGui __instance, Player player) { object? obj = CraftRecipeField?.GetValue(__instance); if (!HellbrothIds.IsHellbroth((Recipe)((obj is Recipe) ? obj : null))) { return true; } if ((Object)(object)player != (Object)null) { ((Character)player).Message((MessageType)2, "$msg_blocked", 0, (Sprite)null, false); } HellbrothRecipePurge.PurgeObjectDb(ObjectDB.instance); return false; } } [HarmonyPatch(typeof(InventoryGui), "UpdateCraftingPanel")] internal static class FilterHellbrothCraftingUi { private static readonly FieldInfo AvailableField = AccessTools.Field(typeof(InventoryGui), "m_availableRecipes"); private static readonly FieldInfo SelectedField = AccessTools.Field(typeof(InventoryGui), "m_selectedRecipe"); private static readonly FieldInfo CraftRecipeField = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe"); private static readonly FieldInfo RecipeFieldOnPair = AccessTools.Field(AccessTools.Inner(typeof(InventoryGui), "RecipeDataPair"), "Recipe"); private static void Postfix(InventoryGui __instance) { if (!(AvailableField?.GetValue(__instance) is IList list) || RecipeFieldOnPair == null) { return; } for (int num = list.Count - 1; num >= 0; num--) { if (list[num] != null && HellbrothIds.IsHellbroth((Recipe)/*isinst with value type is only supported in some contexts*/)) { list.RemoveAt(num); } } ClearSelectedIfHellbroth(__instance); object? obj = CraftRecipeField?.GetValue(__instance); if (HellbrothIds.IsHellbroth((Recipe)((obj is Recipe) ? obj : null))) { CraftRecipeField?.SetValue(__instance, null); } } private static void ClearSelectedIfHellbroth(InventoryGui gui) { object obj = SelectedField?.GetValue(gui); if (obj != null && !(RecipeFieldOnPair == null) && HellbrothIds.IsHellbroth((Recipe)/*isinst with value type is only supported in some contexts*/)) { SelectedField?.SetValue(gui, null); CraftRecipeField?.SetValue(gui, null); } } } [HarmonyPatch(typeof(Humanoid), "UseItem")] internal static class BlockHellbrothUse { private static bool Prefix(Humanoid __instance, ItemData item) { if (!HellbrothIds.IsHellbroth(item)) { return true; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { ((Character)val).Message((MessageType)2, "$msg_blocked", 0, (Sprite)null, false); } return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }