use of logisticspipes.routing.order.LinkedLogisticsOrderList 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);
}
use of logisticspipes.routing.order.LinkedLogisticsOrderList in project LogisticsPipes by RS485.
the class RequestHandler method simulate.
public static void simulate(final EntityPlayer player, final ItemIdentifierStack stack, CoreRoutedPipe pipe) {
final List<IResource> usedList = new ArrayList<>();
final List<IResource> missingList = new ArrayList<>();
RequestTree.simulate(new ItemIdentifierStack(stack), pipe, new RequestLog() {
@Override
public void handleMissingItems(List<IResource> resources) {
missingList.addAll(resources);
}
@Override
public void handleSucessfullRequestOf(IResource item, LinkedLogisticsOrderList parts) {
}
@Override
public void handleSucessfullRequestOfList(List<IResource> resources, LinkedLogisticsOrderList parts) {
usedList.addAll(resources);
}
});
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(ComponentList.class).setUsed(usedList).setMissing(missingList), player);
}
use of logisticspipes.routing.order.LinkedLogisticsOrderList in project LogisticsPipes by RS485.
the class RequestTree method sendUsedMessage.
public void sendUsedMessage(RequestLog log) {
Map<IResource, Integer> used = new HashMap<>();
Map<IResource, Integer> missing = new HashMap<>();
buildUsedMap(used, missing);
log.handleSucessfullRequestOfList(RequestTreeNode.shrinkToList(used), new LinkedLogisticsOrderList());
log.handleMissingItems(RequestTreeNode.shrinkToList(missing));
}
use of logisticspipes.routing.order.LinkedLogisticsOrderList in project LogisticsPipes by RS485.
the class RequestTree method request.
public static int request(ItemIdentifierStack item, IRequestItems requester, RequestLog log, boolean acceptPartial, boolean simulateOnly, boolean logMissing, boolean logUsed, EnumSet<ActiveRequestType> requestFlags, IAdditionalTargetInformation info) {
ItemResource req = new ItemResource(item, requester);
RequestTree tree = new RequestTree(req, null, requestFlags, info);
if (!simulateOnly && (tree.isDone() || ((tree.getPromiseAmount() > 0) && acceptPartial))) {
LinkedLogisticsOrderList list = tree.fullFillAll();
if (log != null) {
log.handleSucessfullRequestOf(req.copyForDisplayWith(item.getStackSize()), list);
}
return tree.getPromiseAmount();
} else {
if (log != null) {
if (!tree.isDone()) {
tree.recurseFailedRequestTree();
}
if (logMissing) {
tree.sendMissingMessage(log);
}
if (logUsed) {
tree.sendUsedMessage(log);
}
}
return tree.getPromiseAmount();
}
}
use of logisticspipes.routing.order.LinkedLogisticsOrderList in project LogisticsPipes by RS485.
the class RequestMonitorPopup method drawMap.
private void drawMap(int par1, int par2) {
tooltip = null;
int mapX = (int) Math.floor(guiMapX);
int mapY = (int) Math.floor(guiMapY - zoom.moveY);
int leftSide = ((width - xSize) / 2);
int topSide = ((height - ySize) / 2);
GL11.glTranslatef(0.0F, 0.0F, 100.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(RequestMonitorPopup.achievementTextures);
drawTexturedModalRect(leftSide, topSide, 0, 0, xSize, ySize);
GL11.glTranslatef(0.0F, 0.0F, -100.0F);
guiTop *= 1 / zoom.zoom;
guiLeft *= 1 / zoom.zoom;
xSize *= 1 / zoom.zoom;
ySize *= 1 / zoom.zoom;
leftSide *= 1 / zoom.zoom;
topSide *= 1 / zoom.zoom;
par1 *= 1 / zoom.zoom;
par2 *= 1 / zoom.zoom;
int innerLeftSide = leftSide + 16;
int innerTopSide = topSide + 17;
zLevel = 0.0F;
GL11.glDepthFunc(GL11.GL_GEQUAL);
GL11.glPushMatrix();
GL11.glScalef(zoom.zoom, zoom.zoom, 1);
GL11.glTranslatef(0.0F, 0.0F, -100.0F);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
int moveBackgroundX = (mapX - minX) % 16;
int moveBackgroundY = (mapY - minY) % 16;
GL11.glColor4f(0.7F, 0.7F, 0.7F, 1.0F);
for (int yVar = 0; yVar * 16 - moveBackgroundY < zoom.bottomRenderBorder; yVar++) {
for (int xVar = 0; xVar * 16 - moveBackgroundX < zoom.rightRenderBorder; xVar++) {
TextureAtlasSprite icon = getTexture(Blocks.STONE);
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
drawTexturedModalRect(innerLeftSide + xVar * 16 - moveBackgroundX, innerTopSide + yVar * 16 - moveBackgroundY, icon, 16, 16);
}
}
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_TEXTURE_2D);
LinkedLogisticsOrderList list = _table.watchedRequests.get(orderId).getValue2();
if (!list.isEmpty()) {
SimpleGraphics.drawVerticalLine(innerLeftSide - mapX + 110, innerTopSide - mapY - 197, innerTopSide - mapY - 180, Color.GREEN, zoom.line);
}
renderLinkedOrderListLines(list, innerLeftSide - mapX + 102, innerTopSide - mapY - 180);
for (Float progress : list.getProgresses()) {
int pos = (int) (29.0F * progress);
drawProgressPoint(innerLeftSide - mapX + 110, innerTopSide - mapY - 197 + pos, 0xff00ff00);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_BLEND);
RenderHelper.enableGUIStandardItemLighting();
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
GL11.glColor4f(0.7F, 0.7F, 0.7F, 1.0F);
mc.getTextureManager().bindTexture(RequestMonitorPopup.achievementTextures);
String s = Integer.toString(orderId);
if (!list.isEmpty()) {
drawTexturedModalRect(innerLeftSide - mapX + 97, innerTopSide - mapY - 220, 0, 202, 26, 26);
mc.fontRenderer.drawStringWithShadow(s, innerLeftSide - mapX + 111 - mc.fontRenderer.getStringWidth(s) / 2, innerTopSide - mapY - 210, 16777215);
} else {
drawTexturedModalRect(innerLeftSide - mapX + 97, innerTopSide - mapY - 162, 0, 202, 26, 26);
mc.fontRenderer.drawStringWithShadow(s, innerLeftSide - mapX + 111 - mc.fontRenderer.getStringWidth(s) / 2, innerTopSide - mapY - 152, 16777215);
}
renderLinkedOrderListItems(list, innerLeftSide - mapX + 102, innerTopSide - mapY - 180, par1, par2);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_BLEND);
guiTop *= zoom.zoom;
guiLeft *= zoom.zoom;
xSize *= zoom.zoom;
ySize *= zoom.zoom;
leftSide *= zoom.zoom;
topSide *= zoom.zoom;
GL11.glScalef(1 / zoom.zoom, 1 / zoom.zoom, 1);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
mc.getTextureManager().bindTexture(RequestMonitorPopup.achievementTextures);
drawTexturedModalRect(leftSide, topSide, 0, 0, xSize, ySize);
GL11.glPopMatrix();
zLevel = 0.0F;
GL11.glDepthFunc(GL11.GL_LEQUAL);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glEnable(GL11.GL_LIGHTING);
RenderHelper.disableStandardItemLighting();
}
Aggregations