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 IsModded v1.0.4
IsModded.dll
Decompiled 2 days agousing System; 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.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("IsModded")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+b0e0b453b4a199f8a40233bb745dd1083c2216e5")] [assembly: AssemblyProduct("IsModded")] [assembly: AssemblyTitle("IsModded")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 IsModded { [BepInPlugin("djc.valheim.ismodded", "IsModded", "1.0.4")] public sealed class IsModded : BaseUnityPlugin { public const string PluginGUID = "djc.valheim.ismodded"; public const string PluginName = "IsModded"; public const string PluginVersion = "1.0.4"; public static ConfigEntry<bool> AllowWhileModded; public static ConfigEntry<bool> AllowWithDevcommands; public static ConfigEntry<bool> HideModdedWatermark; private void Awake() { AllowWhileModded = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowWhileModded", true, "Enable earning achievements while playing with BepInEx / mods loaded. Decouples Game.isModded from cheat checks."); AllowWithDevcommands = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowWithDevcommands", false, "Enable earning achievements even if devcommands / cheats were used on this character or world."); HideModdedWatermark = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual", "HideModdedWatermark", false, "Hide the 'Modded' text watermark on the main menu."); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "djc.valheim.ismodded"); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded successfully! Modded achievements enabled: {2}.", "IsModded", "1.0.4", AllowWhileModded.Value)); } } } namespace IsModded.Patches { [HarmonyPatch(typeof(Achievements), "IsCheatedAtAll")] internal static class Achievements_IsCheatedAtAll_Patch { private struct PatchState { internal bool Applied; internal bool OriginalIsModded; } [HarmonyPrefix] private static bool Prefix(ref bool __result, out PatchState __state) { __state = default(PatchState); if (!IsModded.AllowWhileModded.Value) { return true; } if (IsModded.AllowWithDevcommands.Value) { __result = false; return false; } __state.Applied = true; __state.OriginalIsModded = Game.isModded; Game.isModded = false; return true; } [HarmonyPostfix] private static void Postfix(PatchState __state) { RestoreIsModded(__state); } [HarmonyFinalizer] private static Exception? Finalizer(Exception? __exception, PatchState __state) { RestoreIsModded(__state); return __exception; } private static void RestoreIsModded(PatchState state) { if (state.Applied) { Game.isModded = state.OriginalIsModded; } } } [HarmonyPatch(typeof(FejdStartup), "SetupGui")] internal static class FejdStartup_SetupGui_Patch { [HarmonyPostfix] private static void Postfix(FejdStartup __instance) { if (IsModded.HideModdedWatermark.Value && (Object)(object)__instance.m_moddedText != (Object)null) { __instance.m_moddedText.SetActive(false); } } } [HarmonyPatch(typeof(InventoryGui), "UpdateAchievementsList")] internal static class InventoryGui_UpdateAchievementsList_Patch { [HarmonyPostfix] private static void Postfix(InventoryGui __instance) { if (IsModded.AllowWithDevcommands.Value && (Object)(object)__instance.m_achievementsCheatedText != (Object)null) { ((Component)__instance.m_achievementsCheatedText).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] internal static class Terminal_InitTerminal_Patch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void <Postfix>b__0_0(ConsoleEventArgs args) { bool isModded = Game.isModded; bool flag = (Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile().m_usedCheats; bool flag2 = Achievements.IsWorldCheated(); bool flag3 = (Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory().AnyCheatedItem(); bool num = flag || flag2 || flag3 || isModded; bool flag4 = Achievements.CanGetAchievements(false); args.Context.AddString("=========================================================="); args.Context.AddString(" IsModded :: Valheim 1.0 Achievement Diagnostic "); args.Context.AddString("=========================================================="); args.Context.AddString($" [!] Game.isModded (BepInEx Active) : {isModded}"); args.Context.AddString($" [!] Character Used Devcommands : {flag}"); args.Context.AddString($" [!] World Has Cheat Modifiers : {flag2}"); args.Context.AddString($" [!] Inventory Has Cheated Items : {flag3}"); args.Context.AddString(" ----------------------------------------------------------"); if (num) { args.Context.AddString(" [-] Vanilla 1.0 Engine Verdict : BLOCKED (0 Achievements Allowed)"); args.Context.AddString(" -> Reason: Vanilla ties Game.isModded directly to cheat checks."); } else { args.Context.AddString(" [-] Vanilla 1.0 Engine Verdict : ALLOWED"); } args.Context.AddString(" ----------------------------------------------------------"); if (flag4) { args.Context.AddString(" [+] IsModded Active Status : ACTIVE & RESTORED! (Steam Achievements Working)"); args.Context.AddString(" -> Game.isModded is successfully bypassed for all achievements."); } else { args.Context.AddString(" [X] IsModded Active Status : BLOCKED"); args.Context.AddString(" -> Real cheats detected (character or world)."); } args.Context.AddString("=========================================================="); } } [HarmonyPostfix] private static void Postfix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { bool isModded = Game.isModded; bool flag = (Object)(object)Game.instance != (Object)null && Game.instance.GetPlayerProfile().m_usedCheats; bool flag2 = Achievements.IsWorldCheated(); bool flag3 = (Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory().AnyCheatedItem(); bool num = flag || flag2 || flag3 || isModded; bool flag4 = Achievements.CanGetAchievements(false); args.Context.AddString("=========================================================="); args.Context.AddString(" IsModded :: Valheim 1.0 Achievement Diagnostic "); args.Context.AddString("=========================================================="); args.Context.AddString($" [!] Game.isModded (BepInEx Active) : {isModded}"); args.Context.AddString($" [!] Character Used Devcommands : {flag}"); args.Context.AddString($" [!] World Has Cheat Modifiers : {flag2}"); args.Context.AddString($" [!] Inventory Has Cheated Items : {flag3}"); args.Context.AddString(" ----------------------------------------------------------"); if (num) { args.Context.AddString(" [-] Vanilla 1.0 Engine Verdict : BLOCKED (0 Achievements Allowed)"); args.Context.AddString(" -> Reason: Vanilla ties Game.isModded directly to cheat checks."); } else { args.Context.AddString(" [-] Vanilla 1.0 Engine Verdict : ALLOWED"); } args.Context.AddString(" ----------------------------------------------------------"); if (flag4) { args.Context.AddString(" [+] IsModded Active Status : ACTIVE & RESTORED! (Steam Achievements Working)"); args.Context.AddString(" -> Game.isModded is successfully bypassed for all achievements."); } else { args.Context.AddString(" [X] IsModded Active Status : BLOCKED"); args.Context.AddString(" -> Real cheats detected (character or world)."); } args.Context.AddString("=========================================================="); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("ismodded", "Audit Valheim 1.0 modded achievement status and prove IsModded bypass is active", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } }