diff --git a/src/main/java/wayoftime/bloodmagic/client/screens/ScreenAlchemicalReactionChamber.java b/src/main/java/wayoftime/bloodmagic/client/screens/ScreenAlchemicalReactionChamber.java index 26c23ad7..4fe9ccfb 100644 --- a/src/main/java/wayoftime/bloodmagic/client/screens/ScreenAlchemicalReactionChamber.java +++ b/src/main/java/wayoftime/bloodmagic/client/screens/ScreenAlchemicalReactionChamber.java @@ -54,7 +54,9 @@ public class ScreenAlchemicalReactionChamber extends ScreenBase= 1000) { -// FluidUtil.tryEmptyContainerAndStow(bucketStack, inputTank, outputSlotHandler, 1000, null, true); - this.setInventorySlotContents(INPUT_BUCKET_SLOT, ItemStack.EMPTY); - - if (!res.getResult().isEmpty()) + ItemStack testFullBucketStack = ItemHandlerHelper.copyStackWithSize(fullBucketStack, 1); + LazyOptional fluidHandlerWrapper = FluidUtil.getFluidHandler(testFullBucketStack); + if (fluidHandlerWrapper.isPresent()) { - List arrayList = new ArrayList<>(); - arrayList.add(res.getResult()); + IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get(); + FluidStack transferedStack = FluidUtil.tryFluidTransfer(inputTank, fluidHandler, 1000, false); + if (!transferedStack.isEmpty()) + { + fluidHandler.drain(transferedStack, FluidAction.EXECUTE); + List arrayList = new ArrayList<>(); + arrayList.add(fluidHandler.getContainer()); + if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true)) + { + inputTank.fill(transferedStack, FluidAction.EXECUTE); + outputSlotHandler.canTransferAllItemsToSlots(arrayList, false); + if (fullBucketStack.getCount() > 1) + { + fullBucketStack.setCount(fullBucketStack.getCount() - 1); + } else + { + setInventorySlotContents(INPUT_BUCKET_SLOT, ItemStack.EMPTY); + } + } + } + } + } - outputSlotHandler.canTransferAllItemsToSlots(arrayList, false); + if (!emptyBucketStack.isEmpty() && outputTank.getFluidAmount() >= 1000) + { + ItemStack testEmptyBucketStack = ItemHandlerHelper.copyStackWithSize(emptyBucketStack, 1); + LazyOptional fluidHandlerWrapper = FluidUtil.getFluidHandler(testEmptyBucketStack); + if (fluidHandlerWrapper.isPresent()) + { + IFluidHandlerItem fluidHandler = fluidHandlerWrapper.resolve().get(); + FluidStack transferedStack = FluidUtil.tryFluidTransfer(fluidHandler, outputTank, 1000, false); + if (!transferedStack.isEmpty()) + { + fluidHandler.fill(transferedStack, FluidAction.EXECUTE); + List arrayList = new ArrayList<>(); + arrayList.add(fluidHandler.getContainer()); + if (outputSlotHandler.canTransferAllItemsToSlots(arrayList, true)) + { + outputTank.drain(transferedStack, FluidAction.EXECUTE); + outputSlotHandler.canTransferAllItemsToSlots(arrayList, false); + if (emptyBucketStack.getCount() > 1) + { + emptyBucketStack.setCount(emptyBucketStack.getCount() - 1); + } else + { + setInventorySlotContents(OUTPUT_BUCKET_SLOT, ItemStack.EMPTY); + } + } + } } } diff --git a/src/main/java/wayoftime/bloodmagic/util/MultiSlotItemHandler.java b/src/main/java/wayoftime/bloodmagic/util/MultiSlotItemHandler.java index 65e41136..b902207e 100644 --- a/src/main/java/wayoftime/bloodmagic/util/MultiSlotItemHandler.java +++ b/src/main/java/wayoftime/bloodmagic/util/MultiSlotItemHandler.java @@ -140,6 +140,8 @@ public class MultiSlotItemHandler implements IItemHandler copyList[i] = items[i].copy(); } + boolean hasStashedAll = true; + for (ItemStack stack : stackList) { if (stack.isEmpty()) @@ -167,12 +169,14 @@ public class MultiSlotItemHandler implements IItemHandler if (stack.getCount() <= m) { + ItemStack copy = stack.copy(); if (!simulate) { - ItemStack copy = stack.copy(); copy.grow(stackInSlot.getCount()); copyList[slot] = copy; } + stack = ItemStack.EMPTY; +// System.out.println("Count: " + stack.getCount() + ", m: " + m); break slots; } else @@ -220,6 +224,7 @@ public class MultiSlotItemHandler implements IItemHandler if (!stack.isEmpty()) { + hasStashedAll = false; break; } } @@ -229,7 +234,7 @@ public class MultiSlotItemHandler implements IItemHandler items = copyList; } - return false; + return hasStashedAll; } @Override