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 AltRowHotbarMod v1.2.0
AltRowHotbarMod.dll
Decompiled a month agousing System; using System.Collections.Generic; 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("AltRowHotbarMod")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Supposedly swaps row of inventory with second row while holding alt")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AltRowHotbarMod")] [assembly: AssemblyTitle("AltRowHotbarMod")] [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 AltRowHotbarMod { [BepInPlugin("com.cybin.altrowhotbar", "AltRowHotbar", "1.2.0")] public class AltRowHotbarPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")] public static class HotkeyBar_UpdateIcons_Patch { public static void Prefix(Player player) { if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null || !IsModifierActive()) { return; } Inventory inventory = ((Humanoid)player).GetInventory(); FieldInfo fieldInfo = AccessTools.Field(typeof(Inventory), "m_inventory"); if (fieldInfo == null || !(fieldInfo.GetValue(inventory) is List<ItemData> list)) { return; } foreach (ItemData item in list) { if (item.m_gridPos.y == 0) { item.m_gridPos.y = 99; } else if (item.m_gridPos.y == 1) { item.m_gridPos.y = 0; } } } public static void Postfix(Player player) { if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null || !IsModifierActive()) { return; } Inventory inventory = ((Humanoid)player).GetInventory(); FieldInfo fieldInfo = AccessTools.Field(typeof(Inventory), "m_inventory"); if (fieldInfo == null || !(fieldInfo.GetValue(inventory) is List<ItemData> list)) { return; } foreach (ItemData item in list) { if (item.m_gridPos.y == 0) { item.m_gridPos.y = 1; } else if (item.m_gridPos.y == 99) { item.m_gridPos.y = 0; } } } } [HarmonyPatch(typeof(Player), "UseHotbarItem")] public static class Player_UseHotbarItem_Patch { public static bool Prefix(Player __instance, int index) { if (!IsModifierActive()) { return true; } Inventory inventory = ((Humanoid)__instance).GetInventory(); if (inventory == null) { return true; } ItemData itemAt = inventory.GetItemAt(index - 1, 1); if (itemAt != null) { ((Humanoid)__instance).UseItem((Inventory)null, itemAt, false); } return false; } } private const string ModGUID = "com.cybin.altrowhotbar"; private const string ModName = "AltRowHotbar"; private const string ModVersion = "1.2.0"; private readonly Harmony harmony = new Harmony("com.cybin.altrowhotbar"); public static ConfigEntry<KeyCode> HotbarModifierKey; public static ConfigEntry<bool> UseToggleBehavior; private static bool isToggleActive; private void Awake() { HotbarModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ModifierKey", (KeyCode)308, "The key you interact with to display and use the second row of your inventory on your hotbar (e.g., LeftAlt, LeftControl, V, G)."); UseToggleBehavior = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UseAsToggle", false, "If set to true, pressing the modifier key once will permanently toggle the secondary hotbar row on or off. If false, you must hold the key down."); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AltRowHotbar v1.2.0 initialized. Configurable holding/toggling mechanics active!"); } private void Update() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (InventoryGui.IsVisible() || Menu.IsVisible()) { isToggleActive = false; } else if (Input.GetKeyDown(HotbarModifierKey.Value) && UseToggleBehavior.Value) { isToggleActive = !isToggleActive; } } public static bool IsModifierActive() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (InventoryGui.IsVisible() || Menu.IsVisible()) { return false; } if (UseToggleBehavior.Value) { return isToggleActive; } return Input.GetKey(HotbarModifierKey.Value); } } }