Project Expansion

Project Expansion

4M Downloads

Division by zero extracting items from EMC Link using Pipez item pipes

James103 opened this issue ยท 1 comments

commented

The following line may crash if the EMC value for the ItemStack passed in is zero.

BigInteger maxCount = provider.getEmc().divide(BigInteger.valueOf(ProjectEAPI.getEMCProxy().getValue(itemStack))).min(BigInteger.valueOf(Integer.MAX_VALUE));

To be more specific, if ProjectEAPI.getEMCProxy().getValue(itemStack) returns zero, then the division in the above line tries to divide a BigInteger value by zero, throwing java.lang.ArithmeticException: BigInteger divide by zero and crashing the game.

Fixing this will likely need a guard that checks if ProjectEAPI.getEMCProxy().getValue(itemStack) is zero, and if so returns ItemStack.EMPTY (i.e. no item).

See also AllTheMods/ATM-8#811

commented

Fixed in 1.0.6