Search in sources :

Example 41 with ItemIdentifierStack

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

the class SelectItemOutOfList method renderGuiBackground.

@Override
protected void renderGuiBackground(int par1, int par2) {
    GuiGraphics.drawGuiBackGround(mc, guiLeft, guiTop, right, bottom, zLevel, true);
    //TODO
    fontRendererObj.renderString(StringUtils.translate("misc.selectType"), guiLeft + 10, guiTop + 6, 0x404040, false);
    String pageString = Integer.toString(page + 1) + "/" + Integer.toString(maxPage);
    fontRendererObj.renderString(pageString, guiLeft + 128 - (fontRendererObj.getStringWidth(pageString) / 2), guiTop + 6, 0x404040, false);
    int x = 0;
    int y = -page * 10;
    for (ItemIdentifierStack stack : canidate) {
        if (y >= 0) {
            GuiGraphics.drawSlotBackground(mc, guiLeft + 4 + x * 18, guiTop + 16 + y * 18);
        }
        x++;
        if (x > 7) {
            x = 0;
            y++;
        }
        if (y > 9) {
            break;
        }
    }
}
Also used : ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 42 with ItemIdentifierStack

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

the class ModuleCrafter method registerExtras.

@Override
public void registerExtras(IPromise promise) {
    if (promise instanceof LogisticsDictPromise) {
        _service.getItemOrderManager().addExtra(((LogisticsDictPromise) promise).getResource());
        return;
    } else {
        ItemIdentifierStack stack = new ItemIdentifierStack(promise.getItemType(), promise.getAmount());
        _service.getItemOrderManager().addExtra(new DictResource(stack, null));
    }
}
Also used : LogisticsDictPromise(logisticspipes.routing.LogisticsDictPromise) DictResource(logisticspipes.request.resources.DictResource) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 43 with ItemIdentifierStack

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

the class ModuleOreDictItemSink method buildOreItemIdMap.

private void buildOreItemIdMap() {
    oreItemIdMap = new HashMap<>();
    oreHudList = new ArrayList<>(oreList.size());
    for (String orename : oreList) {
        List<ItemStack> items = OreDictionary.getOres(orename);
        ItemStack stackForHud = null;
        for (ItemStack stack : items) {
            if (stack != null) {
                if (stackForHud == null) {
                    stackForHud = stack;
                }
                if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                    oreItemIdMap.put(stack.getItem(), new TreeSet<>());
                } else {
                    Set<Integer> damageSet = oreItemIdMap.get(stack.getItem());
                    if (damageSet == null) {
                        damageSet = new TreeSet<>();
                        damageSet.add(stack.getItemDamage());
                        oreItemIdMap.put(stack.getItem(), damageSet);
                    } else if (!damageSet.isEmpty()) {
                        damageSet.add(stack.getItemDamage());
                    }
                }
            }
        }
        if (stackForHud != null) {
            ItemStack t = stackForHud.copy();
            if (t.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                t.setItemDamage(0);
            }
            oreHudList.add(new ItemIdentifierStack(ItemIdentifier.get(t), 1));
        } else {
            oreHudList.add(new ItemIdentifierStack(ItemIdentifier.get(Item.getItemFromBlock(Blocks.fire), 0, null), 1));
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 44 with ItemIdentifierStack

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

the class ModuleItemSink method sinksItem.

@Override
public SinkReply sinksItem(ItemIdentifier item, int bestPriority, int bestCustomPriority, boolean allowDefault, boolean includeInTransit) {
    if (_isDefaultRoute && !allowDefault) {
        return null;
    }
    if (bestPriority > _sinkReply.fixedPriority.ordinal() || (bestPriority == _sinkReply.fixedPriority.ordinal() && bestCustomPriority >= _sinkReply.customPriority)) {
        return null;
    }
    if (_filterInventory.containsUndamagedItem(item.getUndamaged())) {
        if (_service.canUseEnergy(1)) {
            return _sinkReply;
        }
        return null;
    }
    if (_service.getUpgradeManager(slot, positionInt).isFuzzyUpgrade()) {
        for (Pair<ItemIdentifierStack, Integer> stack : _filterInventory) {
            if (stack == null) {
                continue;
            }
            if (stack.getValue1() == null) {
                continue;
            }
            ItemIdentifier ident1 = item;
            ItemIdentifier ident2 = stack.getValue1().getItem();
            if (ignoreData.get(stack.getValue2())) {
                ident1 = ident1.getIgnoringData();
                ident2 = ident2.getIgnoringData();
            }
            if (ignoreNBT.get(stack.getValue2())) {
                ident1 = ident1.getIgnoringNBT();
                ident2 = ident2.getIgnoringNBT();
            }
            if (ident1.equals(ident2)) {
                if (_service.canUseEnergy(5)) {
                    return _sinkReply;
                }
                return null;
            }
        }
    }
    if (_isDefaultRoute) {
        if (bestPriority > _sinkReplyDefault.fixedPriority.ordinal() || (bestPriority == _sinkReplyDefault.fixedPriority.ordinal() && bestCustomPriority >= _sinkReplyDefault.customPriority)) {
            return null;
        }
        if (_service.canUseEnergy(1)) {
            return _sinkReplyDefault;
        }
        return null;
    }
    return null;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 45 with ItemIdentifierStack

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

the class RequestRunningCraftingTasks method processPacket.

@Override
public void processPacket(EntityPlayer player) {
    LogisticsStatisticsTileEntity tile = this.getTile(player.getEntityWorld(), LogisticsStatisticsTileEntity.class);
    CoreRoutedPipe pipe = tile.getConnectedPipe();
    if (pipe == null) {
        return;
    }
    List<ItemIdentifierStack> items = new ArrayList<>();
    for (ExitRoute r : pipe.getRouter().getIRoutersByCost()) {
        if (r == null) {
            continue;
        }
        if (r.destination.getPipe() instanceof PipeItemsCraftingLogistics) {
            PipeItemsCraftingLogistics crafting = (PipeItemsCraftingLogistics) r.destination.getPipe();
            List<ItemIdentifierStack> content = crafting.getItemOrderManager().getContentList(player.getEntityWorld());
            items.addAll(content);
        }
    }
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(RunningCraftingTasks.class).setIdentList(items), player);
}
Also used : LogisticsStatisticsTileEntity(logisticspipes.blocks.stats.LogisticsStatisticsTileEntity) PipeItemsCraftingLogistics(logisticspipes.pipes.PipeItemsCraftingLogistics) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ExitRoute(logisticspipes.routing.ExitRoute)

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