Simple Farming

Simple Farming

11M Downloads

IndexOutOfBoundsException on CropHarvest#onCropHarvest()

Elenterius opened this issue ยท 1 comments

commented

When the list of block drops has a size of 1 this error is thrown:
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

This is caused by removing the stack on line 72 causing the list to be empty before the stack can be retrieved on line 76.

for (int i = 0; i < drops.size(); i++) {
if (drops.stream().distinct().limit(2).count() <= 1 || crop == Blocks.POTATOES
|| crop == Blocks.CARROTS) {
drops.remove(0);
event.getWorld()
.addEntity(new ItemEntity((World) event.getWorld(), event.getPos().getX(),
event.getPos().getY(), event.getPos().getZ(),
(ItemStack) drops.get(i)));
}

Luckly this exception fails silently and only crops that have their loot modified are likely to not be harvestable with right click.

commented

issue #71 is the same bug