From 0847fd473751fa49b90b9e774b61d25b1ef7d520 Mon Sep 17 00:00:00 2001 From: Ken W Date: Sat, 11 Dec 2021 01:22:44 -0500 Subject: [PATCH] fix conflict with EquipmentAndQuickSlots mod --- SimpleSort/BepInExPlugin.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/SimpleSort/BepInExPlugin.cs b/SimpleSort/BepInExPlugin.cs index c056a7a..1228efe 100644 --- a/SimpleSort/BepInExPlugin.cs +++ b/SimpleSort/BepInExPlugin.cs @@ -210,14 +210,19 @@ private static void SortByType(SortType type, Inventory inventory, bool asc, boo { int amount = Mathf.Min(items[i].m_shared.m_maxStackSize - items[i].m_stack, items[i + 1].m_stack); items[i].m_stack += amount; - if (amount == items[i + 1].m_stack) - { - items.RemoveAt(i + 1); - } - else + if (amount == items[i + 1].m_stack) { items[i + 1].m_stack -= amount; + items.RemoveAt(i+1); + + // Dummy call, only using it to remove all items from inventory where stack size <= 0 + // This needs to be done because the reference to the original items list gets broken somehow when using EquipmentAndQuickSlots mod + Traverse.Create(inventory).Method("RemoveItem", new object[]{"", 0}).GetValue(); + } else { + items[i + 1].m_stack -= amount; + } } } + switch (type) { case SortType.Name: