use of logisticspipes.request.RequestLog in project LogisticsPipes by RS485.
the class PipeItemsRequestLogistics method simulateRequest.
@Override
public SimulationResult simulateRequest(ItemStack wanted) {
final List<IResource> used = new ArrayList<>();
final List<IResource> missing = new ArrayList<>();
RequestTree.simulate(ItemIdentifier.get(wanted).makeStack(wanted.stackSize), this, new RequestLog() {
@Override
public void handleMissingItems(List<IResource> items) {
missing.addAll(items);
}
@Override
public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
}
@Override
public void handleSucessfullRequestOfList(List<IResource> items, LinkedLogisticsOrderList parts) {
used.addAll(items);
}
});
List<ItemStack> usedList = new ArrayList<>(used.size());
List<ItemStack> missingList = new ArrayList<>(missing.size());
for (IResource e : used) {
if (e instanceof ItemResource) {
usedList.add(((ItemResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
} else if (e instanceof DictResource) {
usedList.add(((DictResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
}
}
for (IResource e : missing) {
if (e instanceof ItemResource) {
missingList.add(((ItemResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
} else if (e instanceof DictResource) {
missingList.add(((DictResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
}
}
SimulationResult r = new SimulationResult();
r.used = usedList;
r.missing = missingList;
return r;
}
use of logisticspipes.request.RequestLog in project LogisticsPipes by RS485.
the class PipeItemsRequestLogistics method performRequest.
@Override
public List<ItemStack> performRequest(ItemStack wanted) {
final List<IResource> missing = new ArrayList<>();
RequestTree.request(ItemIdentifier.get(wanted).makeStack(wanted.stackSize), this, new RequestLog() {
@Override
public void handleMissingItems(List<IResource> items) {
missing.addAll(items);
}
@Override
public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
}
@Override
public void handleSucessfullRequestOfList(List<IResource> items, LinkedLogisticsOrderList parts) {
}
}, null);
List<ItemStack> missingList = new ArrayList<>(missing.size());
for (IResource e : missing) {
if (e instanceof ItemResource) {
missingList.add(((ItemResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
} else if (e instanceof DictResource) {
missingList.add(((DictResource) e).getItem().unsafeMakeNormalStack(e.getRequestedAmount()));
}
}
return missingList;
}
Aggregations