Search in sources :

Example 41 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class DSUInventoryHandler method getItemsAndCount.

@Override
public HashMap<ItemIdentifier, Integer> getItemsAndCount() {
    HashMap<ItemIdentifier, Integer> result = new HashMap<>();
    ItemStack items = _tile.getStoredItemType();
    if (items != null && items.stackSize > 0) {
        result.put(ItemIdentifier.get(items), items.stackSize - (_hideOnePerStack ? 1 : 0));
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack)

Example 42 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class JABBAInventoryHandler method getItemsAndCount.

@Override
public HashMap<ItemIdentifier, Integer> getItemsAndCount() {
    HashMap<ItemIdentifier, Integer> result = new HashMap<>();
    ItemStack items = _storage.getStoredItemType();
    if (items != null && items.stackSize > 0) {
        result.put(ItemIdentifier.get(items), _storage.isCreative() ? (int) (Math.pow(2, 20)) : items.stackSize - (_hideOnePerStack ? 1 : 0));
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack)

Example 43 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class JABBAInventoryHandler method getItems.

@Override
public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> result = new TreeSet<>();
    ItemStack items = _storage.getStoredItemType();
    if (items != null) {
        result.add(ItemIdentifier.get(items));
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemStack(net.minecraft.item.ItemStack)

Example 44 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class RequestTree method request.

public static boolean request(List<ItemIdentifierStack> items, IRequestItems requester, RequestLog log, EnumSet<ActiveRequestType> requestFlags, IAdditionalTargetInformation info) {
    Map<IResource, Integer> messages = new HashMap<>();
    RequestTree tree = new RequestTree(new ItemResource(new ItemIdentifierStack(ItemIdentifier.get(Item.getItemFromBlock(Blocks.stone), 0, null), 0), requester), null, requestFlags, info);
    boolean isDone = true;
    for (ItemIdentifierStack stack : items) {
        ItemIdentifier item = stack.getItem();
        Integer count = messages.get(item);
        if (count == null) {
            count = 0;
        }
        count += stack.getStackSize();
        ItemResource req = new ItemResource(stack, requester);
        messages.put(req, count);
        RequestTree node = new RequestTree(req, tree, requestFlags, info);
        isDone = isDone && node.isDone();
    }
    if (isDone) {
        LinkedLogisticsOrderList list = tree.fullFillAll();
        if (log != null) {
            log.handleSucessfullRequestOfList(RequestTreeNode.shrinkToList(messages), list);
        }
        return true;
    } else {
        if (log != null) {
            tree.logFailedRequestTree(log);
        }
        return false;
    }
}
Also used : LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemResource(logisticspipes.request.resources.ItemResource) IResource(logisticspipes.request.resources.IResource)

Example 45 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class ItemDisplay method renderItemArea.

public void renderItemArea(double zLevel) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    screen.drawRect(left, top, left + width, top + height, Color.GREY);
    tooltip = null;
    int ppi = 0;
    int panelxSize = 20;
    int panelySize = 20;
    int x = 2;
    int y = 2;
    ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
    int scaleX = scaledresolution.getScaledWidth();
    int scaleY = scaledresolution.getScaledHeight();
    int mouseX = Mouse.getX() * scaleX / mc.displayWidth - left;
    int mouseY = scaleY - Mouse.getY() * scaleY / mc.displayHeight - top;
    GL11.glTranslatef(left, top, 0.0F);
    if (!listbyserver) {
        int graphic = ((int) (System.currentTimeMillis() / 250) % 5);
        // GL11.glBindTexture(GL11.GL_TEXTURE_2D,
        // this.mc.renderEngine.getTexture());
        screen.getMC().renderEngine.bindTexture(ItemDisplay.TEXTURE);
        Tessellator tesselator = Tessellator.instance;
        tesselator.startDrawingQuads();
        int xPosition = (width / 2) - 50;
        int yPosition = 40;
        tesselator.addVertexWithUV(xPosition, yPosition + 100, zLevel, 0.04, 0.72 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition + 100, yPosition + 100, zLevel, 0.08, 0.72 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition + 100, yPosition, zLevel, 0.08, 0.69 + (graphic * 0.03125));
        tesselator.addVertexWithUV(xPosition, yPosition, zLevel, 0.04, 0.69 + (graphic * 0.03125));
        tesselator.draw();
    } else {
        RenderHelper.enableGUIStandardItemLighting();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        for (ItemIdentifierStack itemIdentifierStack : _allItems) {
            ItemIdentifier item = itemIdentifierStack.getItem();
            if (search != null && !search.itemSearched(item)) {
                continue;
            }
            ppi++;
            if (ppi <= itemsPerPage * page) {
                continue;
            }
            if (ppi > itemsPerPage * (page + 1)) {
                break;
            }
            ItemStack itemstack = itemIdentifierStack.unsafeMakeNormalStack();
            // -2 on both, because field starts there (see black rect below)
            int realX = x - 2;
            int realY = y - 2;
            Pair<Integer, Integer> pair = new Pair<>(realX, realY);
            if (map.get(pair) != itemIdentifierStack) {
                map.put(pair, itemIdentifierStack);
            }
            if (mouseX >= realX && mouseX < realX + panelxSize && mouseY >= realY && mouseY < realY + panelySize) {
                screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
                screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.DARKER_GREY);
                tooltip = new Object[] { mouseX + left, mouseY + top, itemstack };
            }
            /*if (lastClickedx >= realX && lastClickedx < realX + panelxSize && lastClickedy >= realY && lastClickedy < realY + panelySize) {
					selectedItem = itemIdentifierStack;
					screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
					screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.LIGHTER_GREY);
					screen.drawRect(x, y, x + panelxSize - 4, y + panelySize - 4, Color.DARKER_GREY);
				}
				 */
            if (selectedItem == itemIdentifierStack) {
                screen.drawRect(x - 2, y - 2, x + panelxSize - 2, y + panelySize - 2, Color.BLACK);
                screen.drawRect(x - 1, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.LIGHTER_GREY);
                screen.drawRect(x, y, x + panelxSize - 4, y + panelySize - 4, Color.DARKER_GREY);
                if (renderer != null) {
                    renderer.specialItemRendering(itemIdentifierStack.getItem(), x, y);
                }
            }
            // use GuiGraphics to render the ItemStacks
            ItemStackRenderer itemstackRenderer = new ItemStackRenderer(x, y, 100.0F, true, false, true);
            itemstackRenderer.setItemstack(itemstack).setDisplayAmount(DisplayAmount.HIDE_ONE);
            itemstackRenderer.renderInGui();
            x += panelxSize;
            if (x > width) {
                x = 2;
                y += panelySize;
            }
        }
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
    GL11.glPopMatrix();
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Tessellator(net.minecraft.client.renderer.Tessellator) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack) Pair(logisticspipes.utils.tuples.Pair) ItemStackRenderer(logisticspipes.utils.item.ItemStackRenderer)

Aggregations

ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)69 ItemStack (net.minecraft.item.ItemStack)37 ArrayList (java.util.ArrayList)23 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)23 HashMap (java.util.HashMap)14 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)13 TreeSet (java.util.TreeSet)12 IFilter (logisticspipes.interfaces.routing.IFilter)11 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)11 LinkedList (java.util.LinkedList)10 List (java.util.List)10 Map (java.util.Map)10 SinkReply (logisticspipes.utils.SinkReply)10 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)9 IRouter (logisticspipes.routing.IRouter)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 BitSet (java.util.BitSet)8 Entry (java.util.Map.Entry)7 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)7 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7