if((!_service.getOrderManager().hasOrders(RequestType.CRAFTING) && _extras.isEmpty())) {
if(getUpgradeManager().getCrafterCleanup() > 0) {
List<AdjacentTile> crafters = locateCrafters();
ItemStack extracted = null;
AdjacentTile tile = null;
for (Iterator<AdjacentTile> it = crafters.iterator(); it.hasNext();) {
tile = it.next();
extracted = extractFiltered(tile, _cleanupInventory, cleanupModeIsExclude, getUpgradeManager().getCrafterCleanup() * 3);
if(extracted != null && extracted.stackSize > 0) break;
}
if(extracted != null && extracted.stackSize > 0) {
this._service.queueRoutedItem(SimpleServiceLocator.routedItemHelper.createNewTravelItem(extracted), ForgeDirection.UP);
}
}
return;
}
waitingForCraft = true;
List<AdjacentTile> crafters = locateCrafters();
if (crafters.size() < 1 ) {
if (_service.getOrderManager().hasOrders(RequestType.CRAFTING)) {
_service.getOrderManager().sendFailed();
} else {
_extras.clear();
}
return;
}
List<ItemIdentifierStack> wanteditem = getCraftedItems();
if(wanteditem == null || wanteditem.isEmpty()) return;
_service.spawnParticle(Particles.VioletParticle, 2);
int itemsleft = itemsToExtract();
int stacksleft = stacksToExtract();
while (itemsleft > 0 && stacksleft > 0 && (_service.getOrderManager().hasOrders(RequestType.CRAFTING) || !_extras.isEmpty())) {
LogisticsOrder nextOrder;
boolean processingOrder=false;
if(_service.getOrderManager().hasOrders(RequestType.CRAFTING)){
nextOrder = _service.getOrderManager().peekAtTopRequest(RequestType.CRAFTING); // fetch but not remove.
processingOrder=true;
} else {
nextOrder = _extras.getFirst(); // fetch but not remove.
}
int maxtosend = Math.min(itemsleft, nextOrder.getItem().getStackSize());
maxtosend = Math.min(nextOrder.getItem().getItem().getMaxStackSize(), maxtosend);
// retrieve the new crafted items
ItemStack extracted = null;
AdjacentTile tile = null;
for (Iterator<AdjacentTile> it = crafters.iterator(); it.hasNext();) {
tile = it.next();
extracted = extract(tile, nextOrder.getItem().getItem(), maxtosend);
if (extracted != null && extracted.stackSize > 0) {
break;