Search in sources :

Example 1 with ItemIdentifierInventory

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

the class ItemModule method addInformation.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean flag) {
    if (itemStack.hasTagCompound()) {
        NBTTagCompound nbt = itemStack.getTagCompound();
        if (nbt.hasKey("informationList")) {
            if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) {
                NBTTagList nbttaglist = nbt.getTagList("informationList", 8);
                for (int i = 0; i < nbttaglist.tagCount(); i++) {
                    Object nbttag = nbttaglist.tagList.get(i);
                    String data = ((NBTTagString) nbttag).func_150285_a_();
                    if (data.equals("<inventory>") && i + 1 < nbttaglist.tagCount()) {
                        nbttag = nbttaglist.tagList.get(i + 1);
                        data = ((NBTTagString) nbttag).func_150285_a_();
                        if (data.startsWith("<that>")) {
                            String prefix = data.substring(6);
                            NBTTagCompound module = nbt.getCompoundTag("moduleInformation");
                            int size = module.getTagList(prefix + "items", module.getId()).tagCount();
                            if (module.hasKey(prefix + "itemsCount")) {
                                size = module.getInteger(prefix + "itemsCount");
                            }
                            ItemIdentifierInventory inv = new ItemIdentifierInventory(size, "InformationTempInventory", Integer.MAX_VALUE);
                            inv.readFromNBT(module, prefix);
                            for (int pos = 0; pos < inv.getSizeInventory(); pos++) {
                                ItemIdentifierStack stack = inv.getIDStackInSlot(pos);
                                if (stack != null) {
                                    if (stack.getStackSize() > 1) {
                                        list.add("  " + stack.getStackSize() + "x " + stack.getFriendlyName());
                                    } else {
                                        list.add("  " + stack.getFriendlyName());
                                    }
                                }
                            }
                        }
                        i++;
                    } else {
                        list.add(data);
                    }
                }
            } else {
                list.add(StringUtils.translate(StringUtils.KEY_HOLDSHIFT));
            }
        } else {
            StringUtils.addShiftAddition(itemStack, list);
        }
    } else {
        StringUtils.addShiftAddition(itemStack, list);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) NBTTagString(net.minecraft.nbt.NBTTagString) NBTTagString(net.minecraft.nbt.NBTTagString) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 2 with ItemIdentifierInventory

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

the class ThaumicAspectSinkModuleSlot method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    ModuleThaumicAspectSink module = this.getLogisticsModule(player.getEntityWorld(), ModuleThaumicAspectSink.class);
    if (module == null) {
        return null;
    }
    DummyContainer dummy = new DummyContainer(player.inventory, new ItemIdentifierInventory(1, "TMP", 1));
    dummy.addDummySlot(0, 0, 0);
    dummy.addNormalSlotsForPlayerInventory(0, 0);
    return dummy;
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) ModuleThaumicAspectSink(logisticspipes.modules.ModuleThaumicAspectSink) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory)

Example 3 with ItemIdentifierInventory

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

the class OreDictItemSinkModuleSlot method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    ModuleOreDictItemSink module = this.getLogisticsModule(player.getEntityWorld(), ModuleOreDictItemSink.class);
    if (module == null) {
        return null;
    }
    DummyContainer dummy = new DummyContainer(player.inventory, new ItemIdentifierInventory(1, "TMP", 1));
    dummy.addDummySlot(0, 0, 0);
    dummy.addNormalSlotsForPlayerInventory(0, 0);
    return dummy;
}
Also used : DummyContainer(logisticspipes.utils.gui.DummyContainer) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) ModuleOreDictItemSink(logisticspipes.modules.ModuleOreDictItemSink)

Example 4 with ItemIdentifierInventory

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

the class AssemblyTable method importRecipe.

@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
    if (!(tile instanceof TileAssemblyTable)) {
        return false;
    }
    TileAssemblyTable table = (TileAssemblyTable) tile;
    //current pipe inputs/outputs
    final ItemIdentifierInventory inputs = new ItemIdentifierInventory(inventory.getSizeInventory() - 2, "AssemblyTableDummyInv", 64, false);
    for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
        inputs.setInventorySlotContents(i, inventory.getIDStackInSlot(i));
    }
    ItemStack output = inventory.getStackInSlot(inventory.getSizeInventory() - 2);
    //see if there's a recipe planned in the table that matches the current pipe settings, if yes take the next, otherwise take the first
    FlexibleRecipe<ItemStack> firstRecipe = null;
    FlexibleRecipe<ItemStack> nextRecipe = null;
    boolean takeNext = false;
    for (IFlexibleRecipe<ItemStack> r : AssemblyRecipeManager.INSTANCE.getRecipes()) {
        if (!(r instanceof FlexibleRecipe)) {
            continue;
        }
        if (!((FlexibleRecipe<ItemStack>) r).inputFluids.isEmpty()) {
            continue;
        }
        if (table.isPlanned(r)) {
            if (firstRecipe == null) {
                firstRecipe = (FlexibleRecipe<ItemStack>) r;
            }
            if (takeNext) {
                nextRecipe = (FlexibleRecipe<ItemStack>) r;
                break;
            }
            if (output != null && ItemStack.areItemStacksEqual(output, ((FlexibleRecipe<ItemStack>) r).output)) {
                if (((FlexibleRecipe<ItemStack>) r).canBeCrafted(new // Read Proxy to IInventory
                IFlexibleCrafter() {

                    @Override
                    public int getCraftingItemStackSize() {
                        return inputs.getSizeInventory();
                    }

                    @Override
                    public ItemStack getCraftingItemStack(int paramInt) {
                        return inputs.getStackInSlot(paramInt);
                    }

                    @Override
                    public int getCraftingFluidStackSize() {
                        return 0;
                    }

                    @Override
                    public FluidStack getCraftingFluidStack(int paramInt) {
                        return null;
                    }

                    @Override
                    public ItemStack decrCraftingItemStack(int paramInt1, int paramInt2) {
                        return null;
                    }

                    @Override
                    public FluidStack decrCraftingFluidStack(int paramInt1, int paramInt2) {
                        return null;
                    }
                })) {
                    takeNext = true;
                }
            }
        }
    }
    if (nextRecipe == null) {
        nextRecipe = firstRecipe;
    }
    if (nextRecipe == null) {
        return false;
    }
    // Import
    inventory.setInventorySlotContents(inventory.getSizeInventory() - 2, nextRecipe.output);
    try {
        for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
            inventory.clearInventorySlotContents(i);
        }
        int i = 0;
        for (Object input : nextRecipe.inputItems) {
            ItemStack processed = null;
            if (input instanceof String) {
                List<ItemStack> ores = OreDictionary.getOres((String) input);
                if (ores != null && ores.size() > 0) {
                    input = ores.get(0);
                }
            } else if (input instanceof ItemStack) {
                processed = (ItemStack) input;
            } else if (input instanceof Item) {
                processed = new ItemStack((Item) input);
            } else if (input instanceof Block) {
                processed = new ItemStack((Block) input, 1, 0);
            } else if (input instanceof Integer) {
                processed = null;
            } else {
                throw new IllegalArgumentException("Unknown Object passed to recipe!");
            }
            if (processed != null) {
                inventory.setInventorySlotContents(i, processed);
                ++i;
            }
        }
    } catch (ClassCastException e) {
    // TODO: make it show a nice error or
    // remove this hack altogether.
    }
    // Compact
    inventory.compact_first(9);
    return true;
}
Also used : FluidStack(net.minecraftforge.fluids.FluidStack) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) Item(net.minecraft.item.Item) TileAssemblyTable(buildcraft.silicon.TileAssemblyTable) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) FlexibleRecipe(buildcraft.core.recipes.FlexibleRecipe) IFlexibleRecipe(buildcraft.api.recipes.IFlexibleRecipe)

Example 5 with ItemIdentifierInventory

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

the class OreDictItemSinkModuleInHand method getContainer.

@Override
public DummyContainer getContainer(EntityPlayer player) {
    DummyModuleContainer dummy = new DummyModuleContainer(player, getInvSlot());
    if (!(dummy.getModule() instanceof ModuleOreDictItemSink)) {
        return null;
    }
    dummy.setInventory(new ItemIdentifierInventory(1, "TMP", 1));
    dummy.addDummySlot(0, 0, 0);
    dummy.addNormalSlotsForPlayerInventory(0, 0);
    return dummy;
}
Also used : DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) ModuleOreDictItemSink(logisticspipes.modules.ModuleOreDictItemSink)

Aggregations

ItemIdentifierInventory (logisticspipes.utils.item.ItemIdentifierInventory)8 DummyContainer (logisticspipes.utils.gui.DummyContainer)3 DummyModuleContainer (logisticspipes.utils.gui.DummyModuleContainer)3 IStringBasedModule (logisticspipes.interfaces.IStringBasedModule)2 ModuleOreDictItemSink (logisticspipes.modules.ModuleOreDictItemSink)2 ModuleThaumicAspectSink (logisticspipes.modules.ModuleThaumicAspectSink)2 IFlexibleRecipe (buildcraft.api.recipes.IFlexibleRecipe)1 FlexibleRecipe (buildcraft.core.recipes.FlexibleRecipe)1 TileAssemblyTable (buildcraft.silicon.TileAssemblyTable)1 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)1 Block (net.minecraft.block.Block)1 Item (net.minecraft.item.Item)1 ItemStack (net.minecraft.item.ItemStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 NBTTagString (net.minecraft.nbt.NBTTagString)1 FluidStack (net.minecraftforge.fluids.FluidStack)1