FilteredItemStackHandler causes IndexOutOfBoundsException
Theta-Dev opened this issue ยท 0 comments
A user of my mod (ConstructionWand) reported that my wand's automatic item extraction from containers causes an IndexOutOfBoundsException with the Harvest Rod (and possibly other Reliquary items).
Upon closer inspection, it looks like the harvest rod implements a dynamically sized container which always returns one stack more than what is actually stored (an empty harvest rod reports back 2 slots via getSlots()
for example).
When these slots are queried using getStackInSlot(i)
, the last one does not point to an actual stack and causes a OutOfBounds exception.
This is the code in question:
Reliquary/src/main/java/reliquary/items/util/FilteredItemStackHandler.java
Lines 122 to 125 in 80984f6
Interestingly, the older version of this mod does check if the queried index points to the dynamic slot and returns an empty stack in this case.
Reliquary/src/main/java/xreliquary/items/util/FilteredItemStackHandler.java
Lines 150 to 159 in 8020e80
So I would suggest replacing the function with the 1.16 implementation, that should fix the issue.