Skip to content

Commit d4b2647

Browse files
committed
Added HigherStackSize mod
1 parent 24d0c85 commit d4b2647

4 files changed

Lines changed: 206 additions & 0 deletions

File tree

HigherStackSize/HigherStackSize.cs

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using MelonLoader;
2+
using HarmonyLib;
3+
using Il2Cpp;
4+
5+
[assembly: MelonInfo(typeof(HigherStackSize.HigherStackSizeMod), "Higher Stack Size", "1.0.0", "OGMods")]
6+
[assembly: MelonGame(null, null)]
7+
8+
namespace HigherStackSize;
9+
10+
public class HigherStackSizeMod : MelonMod
11+
{
12+
private const int NEW_STACK_SIZE = 999;
13+
private static readonly HashSet<string> patchedItems = new();
14+
15+
public override void OnInitializeMelon()
16+
{
17+
MelonLogger.Msg("Higher Stack Size loaded!");
18+
}
19+
20+
public static void PatchItem(InventoryItem item)
21+
{
22+
if (item != null && item.HasQuantity && item.MaxStackSize != NEW_STACK_SIZE)
23+
{
24+
item.MaxStackSize = NEW_STACK_SIZE;
25+
26+
if (!patchedItems.Contains(item.Key))
27+
{
28+
patchedItems.Add(item.Key);
29+
MelonLogger.Msg($"Patched {item.Key}: MaxStackSize = {NEW_STACK_SIZE}");
30+
}
31+
}
32+
}
33+
}
34+
35+
[HarmonyPatch(typeof(InventorySlot), "Load")]
36+
public class InventorySlot_Load_Patch
37+
{
38+
[HarmonyPrefix]
39+
public static void Prefix(InventorySlotSaveData saveData)
40+
{
41+
if (saveData == null || string.IsNullOrEmpty(saveData.Key)) return;
42+
43+
try
44+
{
45+
var repository = GameManager.Repository;
46+
if (repository?.Items == null) return;
47+
48+
var item = repository.Items.Get(saveData.Key, false);
49+
HigherStackSizeMod.PatchItem(item);
50+
}
51+
catch (System.Exception e)
52+
{
53+
MelonLogger.Error($"Error in Load Prefix: {e.Message}");
54+
}
55+
}
56+
57+
[HarmonyPostfix]
58+
public static void Postfix(InventorySlot __instance)
59+
{
60+
HigherStackSizeMod.PatchItem(__instance?.Item);
61+
HigherStackSizeMod.PatchItem(__instance?.RequiredItem);
62+
HigherStackSizeMod.PatchItem(__instance?.LockedItem);
63+
}
64+
}
65+
66+
[HarmonyPatch(typeof(InventorySlot), nameof(InventorySlot.AddItem))]
67+
public class InventorySlot_AddItem_Patch
68+
{
69+
[HarmonyPrefix]
70+
public static void Prefix(InventorySlot __instance, InventoryItem item)
71+
{
72+
HigherStackSizeMod.PatchItem(item);
73+
HigherStackSizeMod.PatchItem(__instance?.Item);
74+
HigherStackSizeMod.PatchItem(__instance?.RequiredItem);
75+
HigherStackSizeMod.PatchItem(__instance?.LockedItem);
76+
}
77+
}
78+
79+
[HarmonyPatch(typeof(InventoryData), "Sort")]
80+
public class InventoryData_Sort_Patch
81+
{
82+
[HarmonyPrefix]
83+
public static void Prefix(InventoryData __instance)
84+
{
85+
if (__instance?._inventorySlots == null) return;
86+
87+
foreach (var slot in __instance._inventorySlots)
88+
{
89+
if (slot == null) continue;
90+
91+
HigherStackSizeMod.PatchItem(slot.Item);
92+
HigherStackSizeMod.PatchItem(slot.LockedItem);
93+
HigherStackSizeMod.PatchItem(slot.RequiredItem);
94+
}
95+
}
96+
}
97+
98+
[HarmonyPatch(typeof(InventorySlot), "IsFull")]
99+
public class InventorySlot_IsFull_Patch
100+
{
101+
[HarmonyPrefix]
102+
public static void Prefix(InventorySlot __instance)
103+
{
104+
HigherStackSizeMod.PatchItem(__instance?.Item);
105+
}
106+
}
107+
108+
[HarmonyPatch(typeof(InventorySlot), nameof(InventorySlot.CanAddItem))]
109+
public class InventorySlot_CanAddItem_Patch
110+
{
111+
[HarmonyPrefix]
112+
public static void Prefix(InventorySlot __instance, InventoryItem item)
113+
{
114+
HigherStackSizeMod.PatchItem(item);
115+
HigherStackSizeMod.PatchItem(__instance?.Item);
116+
HigherStackSizeMod.PatchItem(__instance?.RequiredItem);
117+
HigherStackSizeMod.PatchItem(__instance?.LockedItem);
118+
}
119+
}
120+
121+
[HarmonyPatch(typeof(InventorySlot), "TestAddItem")]
122+
public class InventorySlot_TestAddItem_Patch
123+
{
124+
[HarmonyPrefix]
125+
public static void Prefix(InventorySlot __instance, InventoryItem item)
126+
{
127+
HigherStackSizeMod.PatchItem(item);
128+
HigherStackSizeMod.PatchItem(__instance?.Item);
129+
HigherStackSizeMod.PatchItem(__instance?.RequiredItem);
130+
HigherStackSizeMod.PatchItem(__instance?.LockedItem);
131+
}
132+
}
133+
134+
[HarmonyPatch(typeof(CachedAssetDatabase<InventoryItem>), "Get", new Type[] { typeof(string), typeof(bool) })]
135+
public class CachedAssetDatabase_Get_Patch
136+
{
137+
[HarmonyPostfix]
138+
public static void Postfix(InventoryItem __result)
139+
{
140+
HigherStackSizeMod.PatchItem(__result);
141+
}
142+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>disable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Reference Include="0Harmony">
11+
<HintPath>$(MelonLoaderNet6Path)\0Harmony.dll</HintPath>
12+
<Private>false</Private>
13+
</Reference>
14+
<Reference Include="Assembly-CSharp">
15+
<HintPath>$(Il2CppAssembliesPath)\Assembly-CSharp.dll</HintPath>
16+
<Private>false</Private>
17+
</Reference>
18+
<Reference Include="MelonLoader">
19+
<HintPath>$(MelonLoaderNet6Path)\MelonLoader.dll</HintPath>
20+
<Private>false</Private>
21+
</Reference>
22+
<Reference Include="Il2CppInterop.Runtime">
23+
<HintPath>$(MelonLoaderNet6Path)\Il2CppInterop.Runtime.dll</HintPath>
24+
<Private>false</Private>
25+
</Reference>
26+
<Reference Include="Il2Cppmscorlib">
27+
<HintPath>$(Il2CppAssembliesPath)\Il2Cppmscorlib.dll</HintPath>
28+
<Private>false</Private>
29+
</Reference>
30+
<Reference Include="Il2CppSystem">
31+
<HintPath>$(Il2CppAssembliesPath)\Il2CppSystem.dll</HintPath>
32+
<Private>false</Private>
33+
</Reference>
34+
<Reference Include="UnityEngine.CoreModule">
35+
<HintPath>$(Il2CppAssembliesPath)\UnityEngine.CoreModule.dll</HintPath>
36+
<Private>false</Private>
37+
</Reference>
38+
</ItemGroup>
39+
40+
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
41+
<Exec Command="xcopy &quot;$(TargetPath)&quot; &quot;$(GamePath)\Mods\&quot; /Y" />
42+
</Target>
43+
44+
</Project>

LittleRocketLabMods.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToastyDestroysRocks", "Toas
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunFaster", "RunFaster\RunFaster.csproj", "{3EA31384-84CB-4AE2-A789-F9E2B9CED34A}"
1313
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HigherStackSize", "HigherStackSize\HigherStackSize.csproj", "{71DF8F91-D76A-81F5-984E-902E2BC0615A}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
@@ -69,6 +71,18 @@ Global
6971
{3EA31384-84CB-4AE2-A789-F9E2B9CED34A}.Release|x64.Build.0 = Release|Any CPU
7072
{3EA31384-84CB-4AE2-A789-F9E2B9CED34A}.Release|x86.ActiveCfg = Release|Any CPU
7173
{3EA31384-84CB-4AE2-A789-F9E2B9CED34A}.Release|x86.Build.0 = Release|Any CPU
74+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|x64.ActiveCfg = Debug|Any CPU
77+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|x64.Build.0 = Debug|Any CPU
78+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|x86.ActiveCfg = Debug|Any CPU
79+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Debug|x86.Build.0 = Debug|Any CPU
80+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|x64.ActiveCfg = Release|Any CPU
83+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|x64.Build.0 = Release|Any CPU
84+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|x86.ActiveCfg = Release|Any CPU
85+
{71DF8F91-D76A-81F5-984E-902E2BC0615A}.Release|x86.Build.0 = Release|Any CPU
7286
EndGlobalSection
7387
GlobalSection(SolutionProperties) = preSolution
7488
HideSolutionNode = FALSE

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ A collection of MelonLoader mods for the game [Little Rocket Lab](https://store.
44

55
## Mods Included
66

7+
### HigherStackSize
8+
Increases the maximum stack size for all stackable items to 999.
9+
- Automatically patches all inventory items when they're loaded or used
10+
- Works with existing saves and new items
11+
- **Warning:** If you remove this mod, loading a save will reset all item quantities above the default stack size to the default maximum (e.g., items with 50+ will be reduced to the vanilla stack limit)
12+
713
### RunFaster
814
Enables the run speed boost for faster player movement.
915
- Lightweight mod with no debug console or extra features

0 commit comments

Comments
 (0)