use of buildcraft.api.robots.IRequestProvider in project BuildCraft by BuildCraft.
the class AIRobotDeliverRequested method delegateAIEnded.
@Override
public void delegateAIEnded(AIRobot ai) {
if (ai instanceof AIRobotGotoStation) {
if (!ai.success()) {
setSuccess(false);
terminate();
return;
}
IInvSlot slot = InvUtils.getItem(robot, new ArrayStackOrListFilter(requested.getStack()));
if (slot == null) {
setSuccess(false);
terminate();
return;
}
IRequestProvider requester = requested.getRequester(robot.worldObj);
if (requester == null) {
setSuccess(false);
terminate();
return;
}
ItemStack newStack = requester.offerItem(requested.getSlot(), slot.getStackInSlot().copy());
if (newStack == null || newStack.stackSize != slot.getStackInSlot().stackSize) {
slot.setStackInSlot(newStack);
}
terminate();
}
}
use of buildcraft.api.robots.IRequestProvider in project BuildCraft by BuildCraft.
the class AIRobotSearchStackRequest method getAvailableRequests.
private Collection<StackRequest> getAvailableRequests(DockingStation station) {
List<StackRequest> result = new ArrayList<>();
IRequestProvider provider = station.getRequestProvider();
if (provider == null) {
return result;
}
for (int i = 0; i < provider.getRequestsCount(); i++) {
if (provider.getRequest(i) == null) {
continue;
}
StackRequest req = new StackRequest(provider, i, provider.getRequest(i));
req.setStation(station);
if (!robot.getRegistry().isTaken(req.getResourceId(robot.worldObj))) {
result.add(req);
}
}
return result;
}
Aggregations