Project Expansion

Project Expansion

4M Downloads

Divide by Zero crash

Toshy0 opened this issue ยท 3 comments

commented

When using a Hopper or other extraction method on an emc link it causes a divide by zero error in the hopper(or other block) this immediately crashes the game i dont think this is a mod interaction error as I have tried this with different items and storages
crash-2022-04-17_16.58.51-server.txt

commented

Can reproduce in Minecraft 1.16.5 and Project Expansion 1.16.5-1.0.18.

To reproduce:

  1. Place an EMC Link.
  2. Place a hopper below the EMC link.
  3. Set the EMC link to export an item that does not have an EMC value.
  4. Crash - java.lang.ArithmeticException: BigInteger divide by zero because cost is zero

long cost = ProjectEAPI.getEMCProxy().getValue(item);
IKnowledgeProvider provider = ProjectEAPI.getTransmutationProxy().getKnowledgeProviderFor(owner);
BigInteger emc = provider.getEmc();
if (emc.equals(BigInteger.ZERO)) return ItemStack.EMPTY;
int count = amount;
long max = emc.divide(BigInteger.valueOf(cost)).longValue();

commented

This is one cause for it however i dont think it is what caused my game to crash as the two items i was using have EMC andesite alloy from the create mod which has a value around 100 and a diamond saw which is around 8000

commented

Fixed