Search in sources :

Example 6 with PositionedStack

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

the class NEIAssemblyControllerRecipeManager method getShape.

protected MultipleInputOutputRecipe getShape(int programMetadata, int recipeIndex) {
    AssemblyProgram program = ItemAssemblyProgram.getProgramFromItem(programMetadata);
    AssemblyRecipe recipe = program.getRecipeList().get(recipeIndex);
    MultipleInputOutputRecipe shape = new MultipleInputOutputRecipe();
    //for now not useful to put it in an array, but supports when adding multiple input/output.
    ItemStack[] inputStacks = new ItemStack[] { recipe.getInput() };
    for (int i = 0; i < inputStacks.length; i++) {
        PositionedStack stack = new PositionedStack(inputStacks[i], 29 + i % 2 * 18, 66 + i / 2 * 18);
        shape.addIngredient(stack);
    }
    ItemStack[] outputStacks = new ItemStack[] { recipe.getOutput() };
    for (int i = 0; i < outputStacks.length; i++) {
        PositionedStack stack = new PositionedStack(outputStacks[i], 96 + i % 2 * 18, 66 + i / 2 * 18);
        shape.addOutput(stack);
    }
    shape.addIngredient(new PositionedStack(new ItemStack(Itemss.assemblyProgram, 1, programMetadata), 133, 22));
    ItemStack[] requiredMachines = getMachinesFromEnum(program.getRequiredMachines());
    for (int i = 0; i < requiredMachines.length; i++) {
        shape.addIngredient(new PositionedStack(requiredMachines[i], 5 + i * 18, 25));
    }
    return shape;
}
Also used : AssemblyRecipe(pneumaticCraft.api.recipe.AssemblyRecipe) PositionedStack(codechicken.nei.PositionedStack) AssemblyProgram(pneumaticCraft.common.recipes.programs.AssemblyProgram) ItemAssemblyProgram(pneumaticCraft.common.item.ItemAssemblyProgram) ItemStack(net.minecraft.item.ItemStack)

Example 7 with PositionedStack

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

the class NEISolderingStationRecipeManager method getShape.

private ShapedRecipeHandler.CachedShapedRecipe getShape(SolderingStationRecipe recipe) {
    ShapedRecipeHandler.CachedShapedRecipe shape = new ShapedRecipeHandler.CachedShapedRecipe(0, 0, null, recipe.result);
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            if (recipe.source[y * 3 + x] == null) {
                continue;
            }
            PositionedStack stack = new PositionedStack(recipe.source[y * 3 + x], 39 + x * 18, 6 + y * 18);
            stack.setMaxSize(1);
            shape.ingredients.add(stack);
        }
    }
    PositionedStack stack = new PositionedStack(new ItemStack(Items.iron_ingot, 1), 102, 6);
    stack.setMaxSize(1);
    shape.ingredients.add(stack);
    shape.result.relx = 136;
    shape.result.rely = 36;
    return shape;
}
Also used : PositionedStack(codechicken.nei.PositionedStack) ShapedRecipeHandler(codechicken.nei.recipe.ShapedRecipeHandler) ItemStack(net.minecraft.item.ItemStack)

Example 8 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 9 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