private static void OnSpawnedItem(GameObject item, List <KeyValuePair <GameObject, int> > drops, Vector3 centerPos)
        {
#if DEBUG
            //Log.LogDebug($"Attempting to apply modifiers to item {item.name}:{drops.GetHashCode()}");
            //Log.LogDebug($"Possible drops: " + drops.Join(x => $"{x.Key.name}:{x.Value}"));
#endif

            int count = LoopCounter.GetCount(drops);
            int index = GetIndex(drops, count);
            LoopCounter.Increment(drops);

#if DEBUG
            //Log.LogDebug($"[OnSpawnedItem] Count: {count}, Index: {index}");
#endif

            try
            {
                var extendedData = TempDropListCache.GetDrop(drops, index);

                if (extendedData is null)
                {
#if DEBUG
                    //Log.LogDebug($"No config for item {item.name} at index {index}");
#endif
                    return;
                }

#if DEBUG
                //Log.LogDebug($"Found config, applying modifiers to item {item.name}");
#endif

                DropModificationManager.Instance.ApplyModifications(item, extendedData, centerPos);
            }
            catch (Exception e)
            {
                Log.LogError("Error during drop modification.", e);
            }
        }
        private static int AfterSpawnedItem(GameObject item, List <KeyValuePair <GameObject, int> > drops, int index)
        {
            var resultIndex = index;

            try
            {
                var count     = LoopCounter.GetCount(drops) - 1;
                int itemIndex = GetIndex(drops, count);

#if DEBUG
                //Log.LogDebug($"[AfterSpawnedItem] Count: {count}, Index: {itemIndex}");
#endif

                if (itemIndex >= drops.Count)
                {
#if DEBUG
                    // Log.LogWarning($"Ups. Attempting to access drop index {itemIndex} in drop list with count {drops.Count}");
#endif
                    return(resultIndex);
                }

                var drop = drops[itemIndex];

                bool shouldStack = false;

                // Check if we should be stacking the item
                if (drop.Value > 1)
                {
                    if (ConfigurationManager.GeneralConfig.AlwaysAutoStack)
                    {
                        shouldStack = true;
                    }
                    else
                    {
                        var extendedData = TempDropListCache.GetDrop(drops, itemIndex);

                        if (extendedData is not null && extendedData.Config.SetAutoStack)
                        {
                            shouldStack = true;
                        }
                    }
                }

                if (shouldStack)
                {
                    var maxStack  = GetMaxStackSize(drop.Key);
                    var stackSize = Math.Min(maxStack, drop.Value - index);

                    if (stackSize > 1)
                    {
                        // Apply stack to item, and skip loop equivalently.
                        var itemDrop = ComponentCache.GetComponent <ItemDrop>(item);

                        Log.LogTrace($"Stacking item '{drop.Key.name}' {stackSize} times out of maximum {maxStack}.");

                        itemDrop.SetStack(stackSize);

                        // Deduct 1 from result, since loop will increment on its own, and OnSpawnedItem will have incremented loop too.
                        LoopCounter.Increment(drops, stackSize - 1);
                        resultIndex += stackSize - 1;

#if DEBUG
                        //Log.LogTrace($"Setting new loop index: {resultIndex}");
#endif
                    }
                }
            }
            catch (Exception e)
            {
                Log.LogError($"Error while attempting to stack item '{item.name}'. Skipping stacking.", e);
            }

            return(resultIndex);

            int GetMaxStackSize(GameObject item)
            {
                var itemDrop = ComponentCache.GetComponent <ItemDrop>(item);

                if (itemDrop.IsNull() ||
                    itemDrop.m_itemData?.m_shared is null)
                {
                    return(-1);
                }

                return(itemDrop.m_itemData.m_shared.m_maxStackSize);
            }
        }