Mekanism Tools

Mekanism Tools

77M Downloads

Divide-by-zero error on Atomic Disassembler

steven11sjf opened this issue ยท 1 comments

commented

Issue description

I was mining some sand with my disassembler set to fast mode, and the game crashed with a DivideByZero error.

I did some poking around in the repo and it looks like it may apply to current build. This seems to be the location of the crash in current builds:

long energyRequired = getDestroyEnergy(stack, 0);
long energyAvailable = energyContainer.getEnergy();
//If we don't have enough energy to break at full speed check if the reduced speed could actually mine
return energyRequired <= energyAvailable || energyAvailable / (double) energyRequired > Constants.EPSILON;

It used the FloatingLong class that seems to have been removed since, but that call was replaced with a regular division. This would imply that getMode(itemStack).getEfficiency() returned 0 at L187. Beyond that I'm not familiar enough with the codebase to find why.

Steps to reproduce

Unable to reproduce

Minecraft version

1.20.x or earlier (No longer being developed)

NeoForge version

forge 47.3.0

Mekanism version

Older

Other relevant versions

Mekanism version 10.4.8

If a (crash)log is relevant for this issue, link it here: (It's almost always relevant)

https://gist.github.com/steven11sjf/bab23a5965fd57436cd0ccfcc3902ffe

commented

Uhh your crashlog is not a divide by zero error and no idea how you got a null pointer there in the old code.

That said, if energyRequired is 0, then the division wouldn't be performed, as energyRequired <= energyAvailable would be true, thus short circuiting