use of logisticspipes.interfaces.IRequestWatcher in project LogisticsPipes by RS485.
the class RequestHandler method requestMacrolist.
public static void requestMacrolist(NBTTagCompound itemlist, final CoreRoutedPipe requester, final EntityPlayer player) {
if (!requester.useEnergy(5)) {
player.sendMessage(new TextComponentTranslation("lp.misc.noenergy"));
return;
}
NBTTagList list = itemlist.getTagList("inventar", 10);
final List<ItemIdentifierStack> transaction = new ArrayList<>(list.tagCount());
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound itemnbt = list.getCompoundTagAt(i);
NBTTagCompound itemNBTContent = itemnbt.getCompoundTag("nbt");
if (!itemnbt.hasKey("nbt")) {
itemNBTContent = null;
}
ItemIdentifierStack stack = ItemIdentifier.get(Item.getItemById(itemnbt.getInteger("id")), itemnbt.getInteger("data"), itemNBTContent).makeStack(itemnbt.getInteger("amount"));
transaction.add(stack);
}
RequestTree.request(transaction, requester, new RequestLog() {
@Override
public void handleMissingItems(List<IResource> resources) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(true), player);
}
@Override
public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
}
@Override
public void handleSucessfullRequestOfList(List<IResource> resources, LinkedLogisticsOrderList parts) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(MissingItems.class).setItems(resources).setFlag(false), player);
if (requester instanceof IRequestWatcher) {
((IRequestWatcher) requester).handleOrderList(null, parts);
}
}
}, RequestTree.defaultRequestFlags, null);
}
Aggregations