Skip to content

Commit

Permalink
fix divide by zero (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
chochem authored May 29, 2024
1 parent 84d5546 commit f7b15d0
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,15 @@ private void insertFluid(EntityPlayer player, int slotIndex, boolean shift) {
}

// Step 4: calculate outputs
final int emptiedTanks = (int) (totalInserted / fluidPerContainer);
final int partialDrain = (int) (totalInserted % fluidPerContainer);
final int emptiedTanks;
final int partialDrain;
if (fluidPerContainer > 0) {
emptiedTanks = (int) (totalInserted / fluidPerContainer);
partialDrain = (int) (totalInserted % fluidPerContainer);
} else {
emptiedTanks = containersRequestedToInsert;
partialDrain = 0;
}
final int partialTanks = partialDrain > 0 && partialInsertSupported ? 1 : 0;
final int usedTanks = emptiedTanks + partialTanks;
final int untouchedTanks = targetStack.stackSize - usedTanks;
Expand Down

0 comments on commit f7b15d0

Please sign in to comment.