@Override public void update() { if (--remainingDelay > 0) return; IInventory real = inventoryProvider().getInventory(); int side = inventoryProvider().getInterfacedSide(); if (real == null || side < 0) return; InventoryWrapper inv = InventoryWrapper.wrapInventory(real).setSlotsFromSide(side); InventoryWrapper filt = InventoryWrapper.wrapInventory(filter).setSlotsAll(); List<ItemKey> checked = new ArrayList<ItemKey>(9); boolean requestAttempted = false; boolean requestedSomething = false; for (int i = 0; i < filter.getSizeInventory(); i++) { ItemKeyStack keyStack = ItemKeyStack.get(filter.getStackInSlot(i)); if (keyStack == null || checked.contains(keyStack.key())) continue; int toRequest = filt.getItemCount(keyStack.key()); int inInventory = inv.getItemCount(keyStack.key()) + getEnroute(keyStack.key()); int missing = toRequest - inInventory; if (missing <= 0 || (requestWhenEmpty && inInventory > 0)) continue; RequestConsole req = new RequestConsole().setDestination(routeLayer().getRequester()); req.setCrafting(true).setPulling(true).setPartials(true); ItemKeyStack request = ItemKeyStack.get(keyStack.key(), missing); req.makeRequest(request); requestAttempted = true; if (req.requested() > 0) { addToRequestList(request.key(), req.requested()); requestedSomething = true; } } if (requestAttempted) RouteFX.spawnType1( RouteFX.color_request, 8, routeLayer().getCoords(), routeLayer().getWorld()); if (requestAttempted && requestedSomething) operationsWithoutRequest = 0; else operationsWithoutRequest++; remainingDelay = operationDelay() + throttleDelay(); }
public void addFilterInfo(List<String> list) { list.add(EnumChatFormatting.GRAY + "Stock: "); boolean added = false; for (int i = 0; i < filter.getSizeInventory(); i++) { ItemStack stack = filter.getStackInSlot(i); if (stack != null) { list.add( EnumChatFormatting.GRAY + " - " + stack.getDisplayName() + " (" + stack.stackSize + ")"); added = true; } } if (!added) list.add(EnumChatFormatting.GRAY + " - empty"); }