Search in sources :

Example 6 with ItemIdentifierStack

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

the class GuiAddMacro method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    int panelxSize = 20;
    int panelySize = 20;
    int ppi = 0;
    int column = 0;
    int row = 0;
    int wheel = org.lwjgl.input.Mouse.getDWheel();
    if (wheel != 0) {
        if (wheel < 0) {
            mousebutton = 0;
        } else {
            mousebutton = 1;
        }
        mousePosX = mouseX;
        mousePosY = mouseY;
    }
    tooltip = null;
    for (ItemIdentifierStack itemStack : diskProvider.getItemDisplay()._allItems) {
        ItemIdentifier item = itemStack.getItem();
        if (!itemSearched(item)) {
            continue;
        }
        ppi++;
        if (ppi <= 45 * pageAll) {
            continue;
        }
        if (ppi > 45 * (pageAll + 1)) {
            continue;
        }
        ItemStack st = itemStack.unsafeMakeNormalStack();
        int x = guiLeft + 10 + panelxSize * column;
        int y = guiTop + 18 + panelySize * row;
        if (!super.hasSubGui()) {
            if (mouseX >= x && mouseX < x + panelxSize && mouseY >= y && mouseY < y + panelySize) {
                Gui.drawRect(x - 3, y - 1, x + panelxSize - 3, y + panelySize - 3, Color.getValue(Color.BLACK));
                Gui.drawRect(x - 2, y - 0, x + panelxSize - 4, y + panelySize - 4, Color.getValue(Color.DARKER_GREY));
                tooltip = new Object[] { mouseX + guiLeft, mouseY + guiTop, st, false };
            }
            if (mousePosX != 0 && mousePosY != 0) {
                if ((mousePosX >= x && mousePosX < x + panelxSize && mousePosY >= y && mousePosY < y + panelySize) || (mouseX >= x && mouseX < x + panelxSize && mouseY >= y && mouseY < y + panelySize && (wheeldown != 0 || wheelup != 0))) {
                    boolean handled = false;
                    for (ItemIdentifierStack stack : macroItems) {
                        if (stack.getItem().equals(item)) {
                            if (mousebutton == 0 || wheelup != 0) {
                                stack.setStackSize(stack.getStackSize() + (1 + (wheelup != 0 ? wheelup - 1 : 0)));
                            } else if (mousebutton == 1 || wheeldown != 0) {
                                stack.setStackSize(stack.getStackSize() - (1 + (wheeldown != 0 ? wheeldown - 1 : 0)));
                                if (stack.getStackSize() <= 0) {
                                    macroItems.remove(stack);
                                }
                            }
                            handled = true;
                            break;
                        }
                    }
                    if (!handled) {
                        int i = 0;
                        for (ItemIdentifierStack stack : macroItems) {
                            if (item.equals(stack.getItem()) && item.itemDamage < stack.getItem().itemDamage) {
                                if (mousebutton == 0 || wheelup != 0) {
                                    macroItems.add(i, item.makeStack(1 + (wheelup != 0 ? wheelup - 1 : 0)));
                                } else if (mousebutton == 2) {
                                    macroItems.add(i, item.makeStack(64));
                                }
                                handled = true;
                                break;
                            }
                            if (Item.getIdFromItem(item.item) < Item.getIdFromItem(stack.getItem().item)) {
                                if (mousebutton == 0 || wheelup != 0) {
                                    macroItems.add(i, item.makeStack(1 + (wheelup != 0 ? wheelup - 1 : 0)));
                                } else if (mousebutton == 2) {
                                    macroItems.add(i, item.makeStack(64));
                                }
                                handled = true;
                                break;
                            }
                            i++;
                        }
                        if (!handled) {
                            if (mousebutton == 0 || wheelup != 0) {
                                macroItems.addLast(item.makeStack(1 + (wheelup != 0 ? wheelup - 1 : 0)));
                            } else if (mousebutton == 2) {
                                macroItems.addLast(item.makeStack(64));
                            }
                        }
                    }
                    mousePosX = 0;
                    mousePosY = 0;
                }
            }
        }
        column++;
        if (column == 9) {
            row++;
            column = 0;
        }
    }
    ItemStackRenderer.renderItemIdentifierStackListIntoGui(diskProvider.getItemDisplay()._allItems, this, pageAll, guiLeft + 9, guiTop + 17, 9, 45, panelxSize, panelySize, 100.0F, DisplayAmount.NEVER);
    ppi = 0;
    column = 0;
    row = 0;
    for (ItemIdentifierStack itemStack : macroItems) {
        ItemIdentifier item = itemStack.getItem();
        if (!itemSearched(item)) {
            continue;
        }
        ppi++;
        if (ppi <= 9 * pageMacro) {
            continue;
        }
        if (ppi > 9 * (pageMacro + 1)) {
            continue;
        }
        ItemStack st = itemStack.unsafeMakeNormalStack();
        int x = guiLeft + 10 + panelxSize * column;
        int y = guiTop + 150 + panelySize * row;
        if (!super.hasSubGui()) {
            if (mouseX >= x && mouseX < x + panelxSize && mouseY >= y && mouseY < y + panelySize) {
                tooltip = new Object[] { mouseX + guiLeft, mouseY + guiTop, st };
            }
        }
        column++;
        if (column == 9) {
            row++;
            column = 0;
        }
    }
    ItemStackRenderer.renderItemIdentifierStackListIntoGui(macroItems, this, pageMacro, guiLeft + 10, guiTop + 150, 9, 9, panelxSize, panelySize, 100.0F, DisplayAmount.ALWAYS);
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

Example 7 with ItemIdentifierStack

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

the class GuiRecipeImport method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    fontRendererObj.renderString(StringUtils.translate("misc.selectOreDict"), guiLeft + 10, guiTop + 6, 0x404040, false);
    tooltip = null;
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            if (grid[x + y * 3] == null) {
                continue;
            }
            ItemIdentifierStack stack = grid[x + y * 3].order.get(grid[x + y * 3].pos);
            ItemStack itemStack = stack.makeNormalStack();
            FontRenderer font = itemStack.getItem().getFontRenderer(itemStack);
            if (font == null) {
                font = fontRendererObj;
            }
            itemRenderer.renderItemAndEffectIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 45 + x * 18, guiTop + 20 + y * 18);
            // With empty string, because damage value indicator struggles with the depth
            itemRenderer.renderItemOverlayIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 45 + x * 18, guiTop + 20 + y * 18, null);
            if (guiLeft + 45 + x * 18 < mouseX && mouseX < guiLeft + 45 + x * 18 + 16 && guiTop + 20 + y * 18 < mouseY && mouseY < guiTop + 20 + y * 18 + 16 && !hasSubGui()) {
                SimpleGraphics.drawGradientRect(guiLeft + 45 + x * 18, guiTop + 20 + y * 18, guiLeft + 45 + x * 18 + 16, guiTop + 20 + y * 18 + 16, Color.WHITE_50, Color.WHITE_50, 0.0);
                tooltip = new Object[] { guiLeft + mouseX, guiTop + mouseY, itemStack };
            }
        }
    }
    int x = 0;
    int y = 0;
    for (Canidates canidate : list) {
        ItemIdentifierStack stack = canidate.order.get(canidate.pos);
        ItemStack itemStack = stack.makeNormalStack();
        FontRenderer font = itemStack.getItem().getFontRenderer(itemStack);
        if (font == null) {
            font = fontRendererObj;
        }
        itemRenderer.renderItemAndEffectIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 20 + x * 40, guiTop + 90 + y * 40);
        // With empty string, because damage value indicator struggles with the depth
        itemRenderer.renderItemOverlayIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 20 + x * 40, guiTop + 90 + y * 40, "");
        if (guiLeft + 20 + x * 40 < mouseX && mouseX < guiLeft + 20 + x * 40 + 16 && guiTop + 90 + y * 40 < mouseY && mouseY < guiTop + 90 + y * 40 + 16 && !hasSubGui()) {
            SimpleGraphics.drawGradientRect(guiLeft + 20 + x * 40, guiTop + 90 + y * 40, guiLeft + 20 + x * 40 + 16, guiTop + 90 + y * 40 + 16, Color.WHITE_50, Color.WHITE_50, 0.0);
            tooltip = new Object[] { guiLeft + mouseX, guiTop + mouseY, itemStack };
        }
        x++;
        if (x > 2) {
            x = 0;
            y++;
        }
    }
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

Example 8 with ItemIdentifierStack

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

the class GuiLogisticsCraftingTable method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float fA, int iA, int jA) {
    for (GuiButton sycleButton : sycleButtons) {
        sycleButton.visible = _crafter.targetType != null;
    }
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            GuiGraphics.drawSlotBackground(mc, guiLeft + 34 + x * 18, guiTop + 9 + y * 18);
        }
    }
    GuiGraphics.drawSlotBackground(mc, guiLeft + 124, guiTop + 27);
    for (int x = 0; x < 9; x++) {
        for (int y = 0; y < 2; y++) {
            GuiGraphics.drawSlotBackground(mc, guiLeft + 7 + x * 18, guiTop + 79 + y * 18);
        }
    }
    GuiGraphics.drawPlayerInventoryBackground(mc, guiLeft + 8, guiTop + 135);
    ItemIdentifierStack[] items = new ItemIdentifierStack[9];
    for (int i = 0; i < 9; i++) {
        if (_crafter.matrix.getIDStackInSlot(i) != null) {
            items[i] = _crafter.matrix.getIDStackInSlot(i);
        }
    }
    ItemStackRenderer.renderItemIdentifierStackListIntoGui(Arrays.asList(items), null, 0, guiLeft + 8, guiTop + 79, 9, 9, 18, 18, 0.0F, DisplayAmount.NEVER);
    GL11.glTranslatef(0F, 0F, 20F);
    for (int a = 0; a < 9; a++) {
        Gui.drawRect(guiLeft + 8 + (a * 18), guiTop + 80, guiLeft + 24 + (a * 18), guiTop + 96, 0xc08b8b8b);
    }
    GL11.glTranslatef(0F, 0F, -20F);
}
Also used : GuiButton(net.minecraft.client.gui.GuiButton) SmallGuiButton(logisticspipes.utils.gui.SmallGuiButton) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 9 with ItemIdentifierStack

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

the class ModuleCrafter method extractFromIInventoryFiltered.

private ItemStack extractFromIInventoryFiltered(IInventory inv, ItemIdentifierInventory filter, boolean isExcluded, int filterInvLimit, ForgeDirection dir) {
    IInventoryUtil invUtil = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(inv, dir);
    ItemIdentifier wanteditem = null;
    for (ItemIdentifier item : invUtil.getItemsAndCount().keySet()) {
        if (isExcluded) {
            boolean found = false;
            for (int i = 0; i < filter.getSizeInventory() && i < filterInvLimit; i++) {
                ItemIdentifierStack identStack = filter.getIDStackInSlot(i);
                if (identStack == null) {
                    continue;
                }
                if (identStack.getItem().equalsWithoutNBT(item)) {
                    found = true;
                    break;
                }
            }
            if (!found) {
                wanteditem = item;
            }
        } else {
            boolean found = false;
            for (int i = 0; i < filter.getSizeInventory() && i < filterInvLimit; i++) {
                ItemIdentifierStack identStack = filter.getIDStackInSlot(i);
                if (identStack == null) {
                    continue;
                }
                if (identStack.getItem().equalsWithoutNBT(item)) {
                    found = true;
                    break;
                }
            }
            if (found) {
                wanteditem = item;
            }
        }
    }
    if (wanteditem == null) {
        return null;
    }
    int available = invUtil.itemCount(wanteditem);
    if (available == 0) {
        return null;
    }
    if (!_service.useEnergy(neededEnergy() * Math.min(64, available))) {
        return null;
    }
    return invUtil.getMultipleItems(wanteditem, Math.min(64, available));
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 10 with ItemIdentifierStack

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

the class ModuleCrafter method addCrafting.

@Override
public ICraftingTemplate addCrafting(IResource toCraft) {
    List<ItemIdentifierStack> stack = getCraftedItems();
    if (stack == null) {
        return null;
    }
    IReqCraftingTemplate template = null;
    if (this.getUpgradeManager().isFuzzyUpgrade() && outputFuzzyFlags.getBitSet().nextSetBit(0) != -1) {
        if (toCraft instanceof DictResource) {
            for (ItemIdentifierStack craftable : stack) {
                DictResource dict = new DictResource(craftable, null);
                dict.loadFromBitSet(outputFuzzyFlags.getBitSet());
                if (toCraft.matches(craftable.getItem(), IResource.MatchSettings.NORMAL) && dict.matches(((DictResource) toCraft).getItem(), IResource.MatchSettings.NORMAL) && dict.getBitSet().equals(((DictResource) toCraft).getBitSet())) {
                    template = new DictCraftingTemplate(dict, this, priority);
                    break;
                }
            }
        }
    } else {
        for (ItemIdentifierStack craftable : stack) {
            if (toCraft.matches(craftable.getItem(), IResource.MatchSettings.NORMAL)) {
                template = new ItemCraftingTemplate(craftable, this, priority);
                break;
            }
        }
    }
    if (template == null) {
        return null;
    }
    IRequestItems[] target = new IRequestItems[9];
    for (int i = 0; i < 9; i++) {
        target[i] = this;
    }
    boolean hasSatellite = isSatelliteConnected();
    if (!hasSatellite) {
        return null;
    }
    if (!getUpgradeManager().isAdvancedSatelliteCrafter()) {
        if (satelliteId != 0) {
            IRouter r = getSatelliteRouter(-1);
            if (r != null) {
                IRequestItems sat = r.getPipe();
                for (int i = 6; i < 9; i++) {
                    target[i] = sat;
                }
            }
        }
    } else {
        for (int i = 0; i < 9; i++) {
            if (advancedSatelliteIdArray[i] != 0) {
                IRouter r = getSatelliteRouter(i);
                if (r != null) {
                    target[i] = r.getPipe();
                }
            }
        }
    }
    //Check all materials
    for (int i = 0; i < 9; i++) {
        ItemIdentifierStack resourceStack = getMaterials(i);
        if (resourceStack == null || resourceStack.getStackSize() == 0) {
            continue;
        }
        IResource req = null;
        if (getUpgradeManager().isFuzzyUpgrade() && fuzzyCraftingFlagArray[i].getBitSet().nextSetBit(0) != -1) {
            DictResource dict;
            req = dict = new DictResource(resourceStack, target[i]);
            dict.loadFromBitSet(fuzzyCraftingFlagArray[i].getBitSet());
        } else {
            req = new ItemResource(resourceStack, target[i]);
        }
        template.addRequirement(req, new CraftingChassieInformation(i, getPositionInt()));
    }
    int liquidCrafter = getUpgradeManager().getFluidCrafter();
    IRequestFluid[] liquidTarget = new IRequestFluid[liquidCrafter];
    if (!getUpgradeManager().isAdvancedSatelliteCrafter()) {
        if (liquidSatelliteId != 0) {
            IRouter r = getFluidSatelliteRouter(-1);
            if (r != null) {
                IRequestFluid sat = (IRequestFluid) r.getPipe();
                for (int i = 0; i < liquidCrafter; i++) {
                    liquidTarget[i] = sat;
                }
            }
        }
    } else {
        for (int i = 0; i < liquidCrafter; i++) {
            if (liquidSatelliteIdArray[i] != 0) {
                IRouter r = getFluidSatelliteRouter(i);
                if (r != null) {
                    liquidTarget[i] = (IRequestFluid) r.getPipe();
                }
            }
        }
    }
    for (int i = 0; i < liquidCrafter; i++) {
        FluidIdentifier liquid = getFluidMaterial(i);
        int amount = getFluidAmount()[i];
        if (liquid == null || amount <= 0 || liquidTarget[i] == null) {
            continue;
        }
        template.addRequirement(new FluidResource(liquid, amount, liquidTarget[i]), null);
    }
    if (getUpgradeManager().hasByproductExtractor() && getByproductItem() != null) {
        template.addByproduct(getByproductItem());
    }
    return template;
}
Also used : DictResource(logisticspipes.request.resources.DictResource) DictCraftingTemplate(logisticspipes.request.DictCraftingTemplate) IReqCraftingTemplate(logisticspipes.request.IReqCraftingTemplate) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ItemResource(logisticspipes.request.resources.ItemResource) FluidResource(logisticspipes.request.resources.FluidResource) IRouter(logisticspipes.routing.IRouter) IRequestFluid(logisticspipes.interfaces.routing.IRequestFluid) ItemCraftingTemplate(logisticspipes.request.ItemCraftingTemplate) IRequestItems(logisticspipes.interfaces.routing.IRequestItems) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) IResource(logisticspipes.request.resources.IResource)

Aggregations

ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)58 ItemStack (net.minecraft.item.ItemStack)21 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)18 ArrayList (java.util.ArrayList)9 Pair (logisticspipes.utils.tuples.Pair)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 LinkedList (java.util.LinkedList)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 List (java.util.List)4 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)4 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)4 DictResource (logisticspipes.request.resources.DictResource)4 IResource (logisticspipes.request.resources.IResource)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)3 LogisticsCraftingTableTileEntity (logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)3 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)3 ItemResource (logisticspipes.request.resources.ItemResource)3 IRouter (logisticspipes.routing.IRouter)3