if(drained != null && order.getValue1().equals(FluidIdentifier.get(drained))) {
drained = ((ISpecialTankAccessHandler)handler).drainFrom(pair.getValue1(), order.getValue1(), amountToSend, true);
int amount = drained.amount;
amountToSend -= amount;
ItemIdentifierStack stack = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(drained);
IRoutedItem item = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
item.setDestination(order.getValue3().getRouter().getSimpleID());
item.setTransportMode(TransportMode.Active);
this.queueRoutedItem(item, pair.getValue2());
manager.sendAmount(amount);
if(amountToSend <= 0) break;
}
}
}
if(fallback) {
FluidTankInfo[] tanks = ((IFluidHandler)pair.getValue1()).getTankInfo(pair.getValue2().getOpposite());
if(tanks != null) {
for(FluidTankInfo tank:tanks) {
if(tank == null) continue;
FluidStack liquid;
if((liquid = tank.fluid) != null && liquid.fluidID != 0) {
if(order.getValue1().equals(FluidIdentifier.get(liquid))) {
int amount = Math.min(liquid.amount, amountToSend);
FluidStack drained = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amount, false);
if(drained != null && order.getValue1().equals(FluidIdentifier.get(drained))) {
drained = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amount, true);
while(drained.amount < amountToSend) {
FluidStack addition = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amountToSend - drained.amount, false);
if(addition != null && order.getValue1().equals(FluidIdentifier.get(addition))) {
addition = ((IFluidHandler)pair.getValue1()).drain(pair.getValue2().getOpposite(), amountToSend - drained.amount, true);
drained.amount += addition.amount;
} else {
break;
}
}
amount = drained.amount;
amountToSend -= amount;
ItemIdentifierStack stack = SimpleServiceLocator.logisticsFluidManager.getFluidContainer(drained);
IRoutedItem item = SimpleServiceLocator.routedItemHelper.createNewTravelItem(stack);
item.setDestination(order.getValue3().getRouter().getSimpleID());
item.setTransportMode(TransportMode.Active);
this.queueRoutedItem(item, pair.getValue2());
manager.sendAmount(amount);
if(amountToSend <= 0) break;
}
}