Source:
<code>public static FillStatus drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, boolean doDrain) { ItemStack input = inv.getStackInSlot(inputSlot); if (input.isEmpty()) { return FillStatus.INVALID_INPUT; } ItemStack outputStack = inv.getStackInSlot(outputSlot); FluidActionResult drainedResultSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false); if (!drainedResultSimulated.isSuccess()) { return FillStatus.INVALID_INPUT; } ItemStack drainedItemSimulated = drainedResultSimulated.getResult(); if (outputStack.isEmpty() || drainedItemSimulated.isEmpty() || ItemStackUtil.isIdenticalItem(outputStack, drainedItemSimulated) && outputStack.getCount() + drainedItemSimulated.getCount() < outputStack.getMaxStackSize()) { if (doDrain) { FluidActionResult drainedResult = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true); if (drainedResult.isSuccess()) { ItemStack drainedItem = drainedResult.getResult(); if (!drainedItem.isEmpty()) { ItemStack newStack = drainedItem.copy(); if (!outputStack.isEmpty()) { newStack.grow(outputStack.getCount()); } if (!isFillableContainer(newStack) || isFillableContainerAndEmpty(newStack)) { inv.setInventorySlotContents(outputSlot, newStack); inv.decrStackSize(inputSlot, 1); } if(!isFillableEmptyContainer(newStack) && isFillableContainerWithRoom(newStack)) { <START> inv.setInventorySlotContents(inputSlot, newStack.copy()); <END> } } else { inv.decrStackSize(inputSlot, 1); } return FillStatus.SUCCESS; } } return FillStatus.SUCCESS; } return FillStatus.NO_SPACE; }</code><technical_language>copy stack. is copied version of drainedItem</technical_language>

Target:
public static FillStatus drainContainers(IFluidHandler fluidHandler, IInventory inv, int inputSlot, int outputSlot, boolean doDrain) { ItemStack input = inv.getStackInSlot(inputSlot); if (input.isEmpty()) { return FillStatus.INVALID_INPUT; } ItemStack outputStack = inv.getStackInSlot(outputSlot); FluidActionResult drainedResultSimulated = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, false); if (!drainedResultSimulated.isSuccess()) { return FillStatus.INVALID_INPUT; } ItemStack drainedItemSimulated = drainedResultSimulated.getResult(); if (outputStack.isEmpty() || drainedItemSimulated.isEmpty() || ItemStackUtil.isIdenticalItem(outputStack, drainedItemSimulated) && outputStack.getCount() + drainedItemSimulated.getCount() < outputStack.getMaxStackSize()) { if (doDrain) { FluidActionResult drainedResult = FluidUtil.tryEmptyContainer(input, fluidHandler, Fluid.BUCKET_VOLUME, null, true); if (drainedResult.isSuccess()) { ItemStack drainedItem = drainedResult.getResult(); if (!drainedItem.isEmpty()) { ItemStack newStack = drainedItem.copy(); if (!outputStack.isEmpty()) { newStack.grow(outputStack.getCount()); } if (!isFillableContainer(newStack) || isFillableContainerAndEmpty(newStack)) { inv.setInventorySlotContents(outputSlot, newStack); inv.decrStackSize(inputSlot, 1); } if (isDrainableContainer(newStack) && !isEmpty(newStack)) { inv.setInventorySlotContents(inputSlot, newStack); } } else { inv.decrStackSize(inputSlot, 1); } return FillStatus.SUCCESS; } } return FillStatus.SUCCESS; } return FillStatus.NO_SPACE; }