Please disclose if your mod was created primarily 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 NoWorkbench v1.0.0
NoWorkbench.dll
Decompiled 3 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; 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("NoWorkbench")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("NoWorkbench")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c2b0b922-35b0-49d7-bb10-7e0b9dcfdc74")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("lizzardfyll.noworkbench", "No Workbench", "1.0.0")] [BepInProcess("valheim.exe")] public class NoWorkbench : BaseUnityPlugin { private static ConfigEntry<bool> _enableMod; private static ConfigEntry<bool> _enablePortalWood; private static ConfigEntry<bool> _enablePortalStone; private static ConfigEntry<bool> _enableRaft; private static ConfigEntry<bool> _enableKarve; private static ConfigEntry<bool> _enableVikingShip; private static ConfigEntry<bool> _enableVikingShipAshlands; private static ConfigEntry<bool> _enableTurret; private static ConfigEntry<bool> _enableShieldGenerator; private static ConfigEntry<bool> _enableCatapult; private static ConfigEntry<bool> _enableBatteringRam; private static ConfigEntry<bool> _enableTrapTroll; private void Awake() { _enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("Global", "Enable Mod", true, "Enable/disable the entire mod"); _enablePortalWood = ((BaseUnityPlugin)this).Config.Bind<bool>("Portals", "Portal Wood", true, "Remove workbench requirement for wooden portal (portal_wood)"); _enablePortalStone = ((BaseUnityPlugin)this).Config.Bind<bool>("Portals", "Portal Stone", true, "Remove stonecutter requirement for stone portal (portal_stone)"); _enableRaft = ((BaseUnityPlugin)this).Config.Bind<bool>("Ships", "Raft", true, "Remove workbench requirement for raft"); _enableKarve = ((BaseUnityPlugin)this).Config.Bind<bool>("Ships", "Karve", true, "Remove workbench requirement for karve"); _enableVikingShip = ((BaseUnityPlugin)this).Config.Bind<bool>("Ships", "Viking Ship", true, "Remove workbench requirement for viking ship"); _enableVikingShipAshlands = ((BaseUnityPlugin)this).Config.Bind<bool>("Ships", "Viking Ship Ashlands", true, "Remove workbench requirement for viking ship (Ashlands)"); _enableTurret = ((BaseUnityPlugin)this).Config.Bind<bool>("Defense", "Turret", true, "Remove workbench requirement for turret (piece_turret)"); _enableShieldGenerator = ((BaseUnityPlugin)this).Config.Bind<bool>("Defense", "Shield Generator", true, "Remove workbench requirement for shield generator (piece_shieldgenerator)"); _enableTrapTroll = ((BaseUnityPlugin)this).Config.Bind<bool>("Defense", "Troll Trap", true, "Remove workbench requirement for troll trap (piece_trap_troll)"); _enableCatapult = ((BaseUnityPlugin)this).Config.Bind<bool>("Siege", "Catapult", true, "Remove workbench requirement for catapult"); _enableBatteringRam = ((BaseUnityPlugin)this).Config.Bind<bool>("Siege", "Battering Ram", true, "Remove workbench requirement for battering ram"); Harmony.CreateAndPatchAll(typeof(NoWorkbenchPatch), (string)null); Debug.Log((object)"[No Workbench] Loaded!"); } public static bool IsModEnabled() { return _enableMod != null && _enableMod.Value; } public static bool ShouldFreeBuild(string pieceName) { if (!IsModEnabled()) { return false; } string text = pieceName.ToLower(); if (text.Contains("portal_wood") && _enablePortalWood.Value) { return true; } if (text.Contains("portal_stone") && _enablePortalStone.Value) { return true; } if (text.Contains("raft") && _enableRaft.Value) { return true; } if (text.Contains("karve") && _enableKarve.Value) { return true; } if (text.Contains("vikingship") && _enableVikingShip.Value) { return true; } if (text.Contains("vikingship_ashlands") && _enableVikingShipAshlands.Value) { return true; } if (text.Contains("piece_turret") && _enableTurret.Value) { return true; } if (text.Contains("piece_shieldgenerator") && _enableShieldGenerator.Value) { return true; } if (text.Contains("piece_trap_troll") && _enableTrapTroll.Value) { return true; } if (text.Contains("catapult") && _enableCatapult.Value) { return true; } if (text.Contains("batteringram") && _enableBatteringRam.Value) { return true; } return false; } } public static class NoWorkbenchPatch { private static bool IsFreeBuildItem(Piece piece) { if ((Object)(object)piece == (Object)null) { return false; } return NoWorkbench.ShouldFreeBuild(((Object)piece).name); } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Piece), typeof(RequirementMode) })] [HarmonyPostfix] private static void HaveRequirements_Postfix(Player __instance, Piece piece, RequirementMode mode, ref bool __result) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!IsFreeBuildItem(piece) || (int)mode != 0) { return; } bool flag = true; Requirement[] resources = piece.m_resources; foreach (Requirement val in resources) { if ((Object)(object)val.m_resItem != (Object)null && val.m_amount > 0) { string name = val.m_resItem.m_itemData.m_shared.m_name; if (((Humanoid)__instance).GetInventory().CountItems(name, -1, true) < val.m_amount) { flag = false; break; } } } if (!flag) { __result = false; } else if (!__result) { CraftingStation craftingStation = piece.m_craftingStation; piece.m_craftingStation = null; __result = __instance.HaveRequirements(piece, mode); piece.m_craftingStation = craftingStation; } } [HarmonyPatch(typeof(Player), "CheckCanRemovePiece")] [HarmonyPrefix] private static bool CheckCanRemovePiece_Prefix(Player __instance, Piece piece, ref bool __result) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (IsFreeBuildItem(piece)) { if (!PrivateArea.CheckAccess(((Component)piece).transform.position, 0f, true, false)) { ((Character)__instance).Message((MessageType)2, "$msg_privatezone", 0, (Sprite)null); __result = false; return false; } __result = true; return false; } return true; } [HarmonyPatch(typeof(Hud), "SetupPieceInfo")] [HarmonyPostfix] private static void SetupPieceInfo_Postfix(Hud __instance, Piece piece) { if (IsFreeBuildItem(piece)) { int num = piece.m_resources.Length; if (num < __instance.m_requirementItems.Length) { __instance.m_requirementItems[num].SetActive(false); } } } }