Skip to content

Commit

Permalink
Fix gt++ fluid cells not extracting properly (#156)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
firenoo authored Aug 19, 2023
1 parent bcdd765 commit 4de0ee4
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slot
// 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;
}
Expand All @@ -325,8 +325,9 @@ private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slot
// 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.
Expand Down Expand Up @@ -424,7 +425,9 @@ private void insertFluid(ItemStack fluidContainer, EntityPlayer player, int slot
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;
}
Expand Down

0 comments on commit 4de0ee4

Please sign in to comment.