Search in sources :

Example 36 with ItemIdentifierStack

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

the class GuiAddMacro method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id == 0) {
        nextPageAll();
    } else if (guibutton.id == 1) {
        prevPageAll();
    } else if (guibutton.id == 2) {
        nextPageMacro();
    } else if (guibutton.id == 3) {
        prevPageMacro();
    } else if (guibutton.id == 4) {
        if (!(name1 + name2).equals("") && macroItems.size() != 0) {
            NBTTagList inventar = new NBTTagList();
            for (ItemIdentifierStack stack : macroItems) {
                NBTTagCompound itemNBT = new NBTTagCompound();
                itemNBT.setInteger("id", Item.getIdFromItem(stack.getItem().item));
                itemNBT.setInteger("data", stack.getItem().itemDamage);
                if (stack.getItem().tag != null) {
                    itemNBT.setTag("nbt", stack.getItem().tag);
                }
                itemNBT.setInteger("amount", stack.getStackSize());
                inventar.appendTag(itemNBT);
            }
            boolean flag = false;
            NBTTagList list = diskProvider.getDisk().getTagCompound().getTagList("macroList", 10);
            for (int i = 0; i < list.tagCount(); i++) {
                NBTTagCompound tag = list.getCompoundTagAt(i);
                String name = tag.getString("name");
                if (name.equals(name1 + name2)) {
                    flag = true;
                    tag.setTag("inventar", inventar);
                    break;
                }
            }
            if (!flag) {
                NBTTagCompound nbt = new NBTTagCompound();
                nbt.setString("name", name1 + name2);
                nbt.setTag("inventar", inventar);
                list.appendTag(nbt);
            }
            diskProvider.getDisk().getTagCompound().setTag("macroList", list);
            MainProxy.sendPacketToServer(PacketHandler.getPacket(DiscContent.class).setStack(diskProvider.getDisk()).setPosX(diskProvider.getX()).setPosY(diskProvider.getY()).setPosZ(diskProvider.getZ()));
            exitGui();
        } else if (macroItems.size() != 0) {
            setSubGui(new GuiMessagePopup("Please enter a name"));
        } else {
            setSubGui(new GuiMessagePopup("Select some items"));
        }
    } else {
        super.actionPerformed(guibutton);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) DiscContent(logisticspipes.network.packets.orderer.DiscContent) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 37 with ItemIdentifierStack

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

the class GuiSolderingStation method drawGuiContainerBackgroundLayer.

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(GuiSolderingStation.TEXTURE);
    int j = guiLeft;
    int k = guiTop;
    drawTexturedModalRect(j, k, 0, 0, xSize, ySize);
    ItemStackRenderer.renderItemIdentifierStackListIntoGui(tile.getRecipeForTagetAsItemIdentifierStackList(), null, 0, guiLeft + 44, guiTop + 17, 3, 9, 18, 18, 100.0F, DisplayAmount.NEVER);
    ItemStack resultstack = tile.getTargetForTaget();
    if (resultstack == null) {
        resultstack = tile.getTagetForRecipe(false);
    }
    if (resultstack != null) {
        ItemIdentifierStack iis = ItemIdentifier.get(resultstack).makeStack(0);
        List<ItemIdentifierStack> iisl = new LinkedList<>();
        iisl.add(iis);
        ItemStackRenderer.renderItemIdentifierStackListIntoGui(iisl, null, 0, guiLeft + 141, guiTop + 47, 1, 1, 18, 18, 100.0F, DisplayAmount.NEVER);
    }
    mc.renderEngine.bindTexture(GuiSolderingStation.TEXTURE);
    GL11.glDisable(2929);
    for (int a = 0; a < 3; a++) {
        for (int b = 0; b < 3; b++) {
            Gui.drawRect(guiLeft + 44 + (a * 18), guiTop + 17 + (b * 18), guiLeft + 60 + (a * 18), guiTop + 33 + (b * 18), 0xc08b8b8b);
        }
    }
    Gui.drawRect(guiLeft + 141, guiTop + 47, guiLeft + 157, guiTop + 63, 0xc08b8b8b);
    GL11.glEnable(2929);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int level = 100 - tile.heat;
    drawTexturedModalRect(j + 131, k + 19 + (level * 14 / 100), 176, level * 14 / 100, 14, 14 - (level * 14 / 100));
    int progress = tile.progress;
    if (progress >= 50) {
        drawTexturedModalRect(j + 107, k + 38, 176, 14, 10, 24);
        drawTexturedModalRect(j + 117, k + 38, 186, 14, ((progress - 50) * 26 / 100), 24);
    } else {
        if (progress >= 25) {
            drawTexturedModalRect(j + 107, k + 38, 176, 14, ((progress - 25) * 10 / 25), 24);
        }
        drawTexturedModalRect(j + 114, k + 38, 183, 14, 3, (progress * 17 / 50));
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) LinkedList(java.util.LinkedList)

Example 38 with ItemIdentifierStack

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

the class LogisticsFluidManager method getAvailableFluid.

@Override
public TreeSet<ItemIdentifierStack> getAvailableFluid(List<ExitRoute> validDestinations) {
    Map<FluidIdentifier, Integer> allAvailableItems = new HashMap<>();
    for (ExitRoute r : validDestinations) {
        if (r == null) {
            continue;
        }
        if (!r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
            continue;
        }
        if (!(r.destination.getPipe() instanceof IProvideFluids)) {
            continue;
        }
        IProvideFluids provider = (IProvideFluids) r.destination.getPipe();
        Map<FluidIdentifier, Integer> allItems = provider.getAvailableFluids();
        for (Entry<FluidIdentifier, Integer> liquid : allItems.entrySet()) {
            Integer amount = allAvailableItems.get(liquid.getKey());
            if (amount == null) {
                allAvailableItems.put(liquid.getKey(), liquid.getValue());
            } else {
                long addition = ((long) amount) + liquid.getValue();
                if (addition > Integer.MAX_VALUE) {
                    addition = Integer.MAX_VALUE;
                }
                allAvailableItems.put(liquid.getKey(), (int) addition);
            }
        }
    }
    TreeSet<ItemIdentifierStack> itemIdentifierStackList = allAvailableItems.entrySet().stream().map(item -> new ItemIdentifierStack(item.getKey().getItemIdentifier(), item.getValue())).collect(Collectors.toCollection(TreeSet::new));
    return itemIdentifierStackList;
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) IRouter(logisticspipes.routing.IRouter) LogisticsPipes(logisticspipes.LogisticsPipes) IFluidSink(logisticspipes.interfaces.routing.IFluidSink) HashMap(java.util.HashMap) LogisticsFluidContainer(logisticspipes.items.LogisticsFluidContainer) Collectors(java.util.stream.Collectors) ExitRoute(logisticspipes.routing.ExitRoute) TreeSet(java.util.TreeSet) ItemStack(net.minecraft.item.ItemStack) List(java.util.List) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) Map(java.util.Map) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) FluidStack(net.minecraftforge.fluids.FluidStack) IProvideFluids(logisticspipes.interfaces.routing.IProvideFluids) HashMap(java.util.HashMap) IProvideFluids(logisticspipes.interfaces.routing.IProvideFluids) FluidIdentifier(logisticspipes.utils.FluidIdentifier) ExitRoute(logisticspipes.routing.ExitRoute) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 39 with ItemIdentifierStack

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

the class SelectItemOutOfList method mouseClicked.

@Override
protected void mouseClicked(int mouseX, int mouseY, int button) {
    int x = 0;
    int y = -page * 10;
    int count = 0;
    for (ItemIdentifierStack stack : canidate) {
        if (y >= 0) {
            if (guiLeft + 5 + x * 18 < mouseX && mouseX < guiLeft + 5 + x * 18 + 16 && guiTop + 17 + y * 18 < mouseY && mouseY < guiTop + 17 + y * 18 + 16) {
                handler.handleItemChoise(count);
                exitGui();
            }
        }
        x++;
        if (x > 7) {
            x = 0;
            y++;
        }
        count++;
        if (y > 9) {
            break;
        }
    }
    super.mouseClicked(mouseX, mouseY, button);
}
Also used : ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 40 with ItemIdentifierStack

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

the class SelectItemOutOfList method drawGuiContainerForegroundLayer.

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    tooltip = null;
    int x = 0;
    int y = -page * 10;
    for (ItemIdentifierStack stack : canidate) {
        if (y >= 0) {
            ItemStack itemStack = stack.makeNormalStack();
            FontRenderer font = itemStack.getItem().getFontRenderer(itemStack);
            if (font == null) {
                font = fontRendererObj;
            }
            itemRenderer.renderItemAndEffectIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 5 + x * 18, guiTop + 17 + y * 18);
            // With empty string, because damage value indicator struggles with the depth
            itemRenderer.renderItemOverlayIntoGUI(font, mc.renderEngine, itemStack, guiLeft + 5 + x * 18, guiTop + 17 + y * 18, "");
            if (guiLeft + 5 + x * 18 < mouseX && mouseX < guiLeft + 5 + x * 18 + 16 && guiTop + 17 + y * 18 < mouseY && mouseY < guiTop + 17 + y * 18 + 16 && !hasSubGui()) {
                GL11.glDisable(GL11.GL_LIGHTING);
                GL11.glDisable(GL11.GL_DEPTH_TEST);
                GL11.glColorMask(true, true, true, false);
                SimpleGraphics.drawGradientRect(guiLeft + 5 + x * 18, guiTop + 17 + y * 18, guiLeft + 5 + x * 18 + 16, guiTop + 17 + y * 18 + 16, Color.WHITE_50, Color.WHITE_50, 0.0);
                GL11.glColorMask(true, true, true, true);
                GL11.glEnable(GL11.GL_LIGHTING);
                GL11.glEnable(GL11.GL_DEPTH_TEST);
                tooltip = new Object[] { guiLeft + mouseX, guiTop + mouseY, itemStack };
            }
        }
        x++;
        if (x > 7) {
            x = 0;
            y++;
        }
        if (y > 9) {
            break;
        }
    }
}
Also used : FontRenderer(net.minecraft.client.gui.FontRenderer) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

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