use of buildcraft.lib.inventory.filter.InvertedFluidFilter in project BuildCraft by BuildCraft.
the class PipeBehaviourWoodDiamond method extractFluid.
@Override
protected FluidStack extractFluid(IFlowFluid flow, EnumFacing dir, int millibuckets, boolean simulate) {
if (filters.getStackInSlot(currentFilter).isEmpty()) {
advanceFilter();
}
switch(filterMode) {
default:
case WHITE_LIST:
if (filters.extract(s -> true, 1, 1, true).isEmpty()) {
return flow.tryExtractFluid(millibuckets, dir, null, simulate);
}
// Firstly try the advanced version - if that fails we will need to try the basic version
ActionResult<FluidStack> result = flow.tryExtractFluidAdv(millibuckets, dir, new ArrayFluidFilter(filters.stacks), simulate);
FluidStack extracted = result.getResult();
if (result.getType() != EnumActionResult.PASS) {
return extracted;
}
if (extracted == null || extracted.amount <= 0) {
for (int i = 0; i < filters.getSlots(); i++) {
ItemStack stack = filters.getStackInSlot(i);
if (stack.isEmpty()) {
continue;
}
extracted = flow.tryExtractFluid(millibuckets, dir, FluidUtil.getFluidContained(stack), simulate);
if (extracted != null && extracted.amount > 0) {
return extracted;
}
}
}
return null;
case BLACK_LIST:
// We cannot fallback to the basic version - only use the advanced version
InvertedFluidFilter filter = new InvertedFluidFilter(new ArrayFluidFilter(filters.stacks));
return flow.tryExtractFluidAdv(millibuckets, dir, filter, simulate).getResult();
case ROUND_ROBIN:
// We can't do this -- amounts might differ and its just ugly
return null;
}
}
Aggregations