Fixed an IndexOutOfBounds error in the inventory system.