From f7b15d02831befea6caa681dfed638b2460d5fd1 Mon Sep 17 00:00:00 2001 From: chochem <40274384+chochem@users.noreply.github.com> Date: Wed, 29 May 2024 11:31:17 +0100 Subject: [PATCH] fix divide by zero (#207) --- .../client/gui/container/ContainerFluidMonitor.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidMonitor.java b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidMonitor.java index e73f55e3f..a5bc00bf3 100644 --- a/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidMonitor.java +++ b/src/main/java/com/glodblock/github/client/gui/container/ContainerFluidMonitor.java @@ -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;