From 4de0ee4b1a136bc834df269ce06290c01ad27ee3 Mon Sep 17 00:00:00 2001 From: firenoo <49818773+firenoo@users.noreply.github.com> Date: Sat, 19 Aug 2023 03:34:36 -0700 Subject: [PATCH] Fix gt++ fluid cells not extracting properly (#156) * Fix gt++ fluid cells not extracting properly If GT++ fluid tank item sees a stacksize > 1, it refuses to fill/drain the tank item, so we need to set the tank size to 1 before performing tests. * Fix GT cells not working with fluid terminal GT cells use IFluidContainerItem, despite the fact that they act like FluidContainerRegistry items. Unfortunately this threw off the test code; need to extract the entire container at a time for the test. --- .../client/gui/container/ContainerFluidMonitor.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 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 2592d23e..ad1bb187 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 @@ -306,7 +306,7 @@ public class ContainerFluidMonitor extends FCContainerMonitor { // Step 2: Find out how much fluid we can extract from the container. If this is null or 0, return. ItemStack test = fluidContainer.copy(); test.stackSize = 1; - FluidStack fluidStack = fcItem.drain(test, 1, false); + FluidStack fluidStack = fcItem.drain(test, fluidPerContainer, false); if (fluidStack == null || fluidStack.amount == 0) { return; } @@ -325,8 +325,9 @@ public class ContainerFluidMonitor extends FCContainerMonitor { // 4.2: Handle empty output if (insertionResults[ACT_IDX] > 0) { emptyStack = fluidContainer.copy(); - emptyStack.stackSize = insertionResults[ACT_IDX]; + emptyStack.stackSize = 1; fcItem.drain(emptyStack, fluidPerContainer, true); + emptyStack.stackSize = insertionResults[ACT_IDX]; } } else if (FluidContainerRegistry.isContainer(fluidContainer)) { // Step 1: Find out how much fluid we can insert. @@ -424,7 +425,9 @@ public class ContainerFluidMonitor extends FCContainerMonitor { private void extractFluid(IAEFluidStack fluid, ItemStack fluidContainer, EntityPlayer player, int heldContainers) { // Step 1: Check if fluid can actually get filled into the fluidContainer if (fluidContainer.getItem() instanceof IFluidContainerItem fcItem) { - int test = fcItem.fill(fluidContainer, fluid.getFluidStack(), false); + ItemStack testStack = fluidContainer.copy(); + testStack.stackSize = 1; + int test = fcItem.fill(testStack, fluid.getFluidStack(), false); if (test == 0) { return; }