Search in sources :

Example 1 with PositionedStack

use of codechicken.nei.PositionedStack in project BluePower by Qmunity.

the class ProjectTableOverlayHandler method getPermutationIngredients.

private List<DistributedIngred> getPermutationIngredients(List<PositionedStack> ingredients) {
    ArrayList<DistributedIngred> ingredStacks = new ArrayList<DistributedIngred>();
    for (// work out what we need
    PositionedStack posstack : // work out what we need
    ingredients) {
        for (ItemStack pstack : posstack.items) {
            DistributedIngred istack = findIngred(ingredStacks, pstack);
            if (istack == null)
                ingredStacks.add(istack = new DistributedIngred(pstack));
            istack.recipeAmount += pstack.stackSize;
        }
    }
    return ingredStacks;
}
Also used : PositionedStack(codechicken.nei.PositionedStack) ArrayList(java.util.ArrayList) DistributedIngred(codechicken.nei.recipe.DefaultOverlayHandler.DistributedIngred) ItemStack(net.minecraft.item.ItemStack)

Example 2 with PositionedStack

use of codechicken.nei.PositionedStack in project LogisticsPipes by RS485.

the class LogisticsCraftingOverlayHandler method overlayRecipe.

@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
    TileEntity tile;
    LogisticsBaseGuiScreen gui;
    if (firstGui instanceof GuiLogisticsCraftingTable) {
        tile = ((GuiLogisticsCraftingTable) firstGui)._crafter;
        gui = (GuiLogisticsCraftingTable) firstGui;
    } else if (firstGui instanceof GuiRequestTable) {
        tile = ((GuiRequestTable) firstGui)._table.container;
        gui = (GuiRequestTable) firstGui;
    } else {
        return;
    }
    ItemStack[] stack = new ItemStack[9];
    ItemStack[][] stacks = new ItemStack[9][];
    boolean hasCanidates = false;
    NEISetCraftingRecipe packet = PacketHandler.getPacket(NEISetCraftingRecipe.class);
    for (PositionedStack ps : recipe.getIngredientStacks(recipeIndex)) {
        int x = (ps.relx - 25) / 18;
        int y = (ps.rely - 6) / 18;
        int slot = x + y * 3;
        if (x < 0 || x > 2 || y < 0 || y > 2 || slot < 0 || slot > 8) {
            FMLClientHandler.instance().getClient().thePlayer.sendChatMessage("Internal Error. This button is broken.");
            return;
        }
        if (slot < 9) {
            stack[slot] = ps.items[0];
            List<ItemStack> list = new ArrayList<>(Arrays.asList(ps.items));
            Iterator<ItemStack> iter = list.iterator();
            while (iter.hasNext()) {
                ItemStack wildCardCheckStack = iter.next();
                if (wildCardCheckStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                    iter.remove();
                    wildCardCheckStack.getItem().getSubItems(wildCardCheckStack.getItem(), wildCardCheckStack.getItem().getCreativeTab(), list);
                    iter = list.iterator();
                }
            }
            stacks[slot] = list.toArray(new ItemStack[0]);
            if (stacks[slot].length > 1) {
                hasCanidates = true;
            } else if (stacks[slot].length == 1) {
                stack[slot] = stacks[slot][0];
            }
        }
    }
    if (hasCanidates) {
        gui.setSubGui(new GuiRecipeImport(tile, stacks));
    } else {
        MainProxy.sendPacketToServer(packet.setContent(stack).setPosX(tile.xCoord).setPosY(tile.yCoord).setPosZ(tile.zCoord));
    }
}
Also used : GuiRecipeImport(logisticspipes.gui.popup.GuiRecipeImport) GuiLogisticsCraftingTable(logisticspipes.gui.GuiLogisticsCraftingTable) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) PositionedStack(codechicken.nei.PositionedStack) ArrayList(java.util.ArrayList) TileEntity(net.minecraft.tileentity.TileEntity) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) NEISetCraftingRecipe(logisticspipes.network.packets.NEISetCraftingRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 3 with PositionedStack

use of codechicken.nei.PositionedStack in project PneumaticCraft by MineMaarten.

the class NEIEtchingAcidManager method getAllRecipes.

@Override
protected List<MultipleInputOutputRecipe> getAllRecipes() {
    List<MultipleInputOutputRecipe> recipes = new ArrayList<MultipleInputOutputRecipe>();
    MultipleInputOutputRecipe recipe = new MultipleInputOutputRecipe();
    recipe.addIngredient(new PositionedStack(new ItemStack(Itemss.emptyPCB), 41, 80));
    recipe.addIngredient(new PositionedStack(new ItemStack(Fluids.getBucket(Fluids.etchingAcid)), 73, 80));
    recipe.addOutput(new PositionedStack(new ItemStack(Itemss.unassembledPCB), 105, 80));
    recipes.add(recipe);
    return recipes;
}
Also used : PositionedStack(codechicken.nei.PositionedStack) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack)

Example 4 with PositionedStack

use of codechicken.nei.PositionedStack in project BluePower by Qmunity.

the class ProjectTableOverlayHandler method assignIngredients.

private List<IngredientDistribution> assignIngredients(List<PositionedStack> ingredients, List<DistributedIngred> ingredStacks) {
    ArrayList<IngredientDistribution> assignedIngredients = new ArrayList<IngredientDistribution>();
    for (// assign what we need and have
    PositionedStack posstack : // assign what we need and have
    ingredients) {
        DistributedIngred biggestIngred = null;
        ItemStack permutation = null;
        int biggestSize = 0;
        for (ItemStack pstack : posstack.items) {
            for (int j = 0; j < ingredStacks.size(); j++) {
                DistributedIngred istack = ingredStacks.get(j);
                if (!InventoryUtils.canStack(pstack, istack.stack) || istack.invAmount - istack.distributed < pstack.stackSize)
                    continue;
                int relsize = (istack.invAmount - istack.invAmount / istack.recipeAmount * istack.distributed) / pstack.stackSize;
                if (relsize > biggestSize) {
                    biggestSize = relsize;
                    biggestIngred = istack;
                    permutation = pstack;
                    break;
                }
            }
        }
        if (// not enough ingreds
        biggestIngred == null)
            return null;
        biggestIngred.distributed += permutation.stackSize;
        assignedIngredients.add(new IngredientDistribution(biggestIngred, permutation));
    }
    return assignedIngredients;
}
Also used : IngredientDistribution(codechicken.nei.recipe.DefaultOverlayHandler.IngredientDistribution) PositionedStack(codechicken.nei.PositionedStack) ArrayList(java.util.ArrayList) DistributedIngred(codechicken.nei.recipe.DefaultOverlayHandler.DistributedIngred) ItemStack(net.minecraft.item.ItemStack)

Example 5 with PositionedStack

use of codechicken.nei.PositionedStack in project BluePower by Qmunity.

the class ProjectTableOverlayHandler method mapIngredSlots.

@SuppressWarnings("unchecked")
public Slot[][] mapIngredSlots(GuiContainer gui, List<PositionedStack> ingredients) {
    Slot[][] recipeSlotList = new Slot[ingredients.size()][];
    for (// identify slots
    int i = 0; // identify slots
    i < ingredients.size(); // identify slots
    i++) {
        LinkedList<Slot> recipeSlots = new LinkedList<Slot>();
        PositionedStack pstack = ingredients.get(i);
        for (Slot slot : (List<Slot>) gui.inventorySlots.inventorySlots) {
            if (slot.xDisplayPosition == pstack.relx + 9 && slot.yDisplayPosition == pstack.rely + 10) {
                recipeSlots.add(slot);
                break;
            }
        }
        recipeSlotList[i] = recipeSlots.toArray(new Slot[0]);
    }
    return recipeSlotList;
}
Also used : PositionedStack(codechicken.nei.PositionedStack) Slot(net.minecraft.inventory.Slot) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Aggregations

PositionedStack (codechicken.nei.PositionedStack)9 ItemStack (net.minecraft.item.ItemStack)8 ArrayList (java.util.ArrayList)7 DistributedIngred (codechicken.nei.recipe.DefaultOverlayHandler.DistributedIngred)2 IngredientDistribution (codechicken.nei.recipe.DefaultOverlayHandler.IngredientDistribution)1 ShapedRecipeHandler (codechicken.nei.recipe.ShapedRecipeHandler)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 GuiLogisticsCraftingTable (logisticspipes.gui.GuiLogisticsCraftingTable)1 GuiRequestTable (logisticspipes.gui.orderer.GuiRequestTable)1 GuiRecipeImport (logisticspipes.gui.popup.GuiRecipeImport)1 NEISetCraftingRecipe (logisticspipes.network.packets.NEISetCraftingRecipe)1 LogisticsBaseGuiScreen (logisticspipes.utils.gui.LogisticsBaseGuiScreen)1 Slot (net.minecraft.inventory.Slot)1 TileEntity (net.minecraft.tileentity.TileEntity)1 Pair (org.apache.commons.lang3.tuple.Pair)1 AssemblyRecipe (pneumaticCraft.api.recipe.AssemblyRecipe)1 PressureChamberRecipe (pneumaticCraft.api.recipe.PressureChamberRecipe)1 ItemAssemblyProgram (pneumaticCraft.common.item.ItemAssemblyProgram)1 AssemblyProgram (pneumaticCraft.common.recipes.programs.AssemblyProgram)1