Search in sources :

Example 1 with AssemblyRecipe

use of pneumaticCraft.api.recipe.AssemblyRecipe in project PneumaticCraft by MineMaarten.

the class CraftingRegistrator method calculateAssemblyChain.

private static void calculateAssemblyChain(List<AssemblyRecipe> firstRecipeList, List<AssemblyRecipe> secondRecipeList, List<AssemblyRecipe> totalRecipeList) {
    for (AssemblyRecipe firstRecipe : firstRecipeList) {
        for (AssemblyRecipe secondRecipe : secondRecipeList) {
            if (firstRecipe.getOutput().isItemEqual(secondRecipe.getInput()) && firstRecipe.getOutput().stackSize % secondRecipe.getInput().stackSize == 0 && secondRecipe.getOutput().getMaxStackSize() >= secondRecipe.getOutput().stackSize * (firstRecipe.getOutput().stackSize / secondRecipe.getInput().stackSize)) {
                ItemStack output = secondRecipe.getOutput().copy();
                output.stackSize = output.stackSize * (firstRecipe.getOutput().stackSize / secondRecipe.getInput().stackSize);
                totalRecipeList.add(new AssemblyRecipe(firstRecipe.getInput(), output));
            }
        }
    }
}
Also used : AssemblyRecipe(pneumaticCraft.api.recipe.AssemblyRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 2 with AssemblyRecipe

use of pneumaticCraft.api.recipe.AssemblyRecipe in project PneumaticCraft by MineMaarten.

the class IntegratorAssembly method onCommandInvoke.

@Override
public void onCommandInvoke(String[] arguments, List<IReservedSpace> reservedSpaces, List<LocatedString> locatedStrings, List<LocatedStack> locatedStacks, List<IWidget> locatedTextures) throws IllegalArgumentException {
    if (arguments.length != 3 && arguments.length != 4)
        throw new IllegalArgumentException("Code needs 3 or 4 arguments!");
    int x;
    try {
        x = Integer.parseInt(arguments[0]);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException("The first parameter (the x coordinate) contains an invalid number. Check for invalid characters!");
    }
    int y;
    try {
        y = Integer.parseInt(arguments[1]);
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException("The second parameter (the y coordinate) contains an invalid number. Check for invalid characters!");
    }
    locatedTextures.add(new LocatedTexture(TextureSupplier.getTexture(Textures.ICON_LOCATION + "textures/wiki/assemblyLineRecipe.png"), x, y, 1 / GuiWiki.TEXT_SCALE));
    int recipeIndex = 0;
    if (arguments.length == 4) {
        try {
            recipeIndex = Integer.parseInt(arguments[3]);
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("The fourth parameter (the recipeIndex) contains an invalid number. Check for invalid characters!");
        }
    }
    int[] hits = new int[] { recipeIndex };
    int program = ItemAssemblyProgram.DRILL_LASER_DAMAGE;
    AssemblyRecipe foundRecipe = findRecipe(hits, AssemblyRecipe.drillRecipes, arguments[2]);
    if (foundRecipe == null) {
        foundRecipe = findRecipe(hits, AssemblyRecipe.laserRecipes, arguments[2]);
    } else {
        program = ItemAssemblyProgram.DRILL_DAMAGE;
    }
    if (foundRecipe == null) {
        foundRecipe = findRecipe(hits, AssemblyRecipe.drillLaserRecipes, arguments[2]);
    } else {
        program = ItemAssemblyProgram.LASER_DAMAGE;
    }
    if (foundRecipe == null)
        throw new IllegalArgumentException("No recipe found for the string " + arguments[2] + " and the requested index " + recipeIndex + ".");
    locatedStacks.add(new LocatedStack(foundRecipe.getInput(), (int) (GuiWiki.TEXT_SCALE * x) + 1, (int) (GuiWiki.TEXT_SCALE * y) + 46));
    locatedStacks.add(new LocatedStack(foundRecipe.getOutput(), (int) (GuiWiki.TEXT_SCALE * x) + 68, (int) (GuiWiki.TEXT_SCALE * y) + 46));
    locatedStacks.add(new LocatedStack(new ItemStack(Itemss.assemblyProgram, 1, program), (int) (GuiWiki.TEXT_SCALE * x) + 78, (int) (GuiWiki.TEXT_SCALE * y) + 15));
    locatedStrings.add(new LocatedString("Program:", x + 150, y + 5, 0xFF000000, false));
    locatedStrings.add(new LocatedString("Assembly Line", x + 40, y + 30, 0xFF000000, false));
}
Also used : AssemblyRecipe(pneumaticCraft.api.recipe.AssemblyRecipe) LocatedStack(igwmod.gui.LocatedStack) LocatedString(igwmod.gui.LocatedString) LocatedTexture(igwmod.gui.LocatedTexture) ItemStack(net.minecraft.item.ItemStack)

Example 3 with AssemblyRecipe

use of pneumaticCraft.api.recipe.AssemblyRecipe 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 4 with AssemblyRecipe

use of pneumaticCraft.api.recipe.AssemblyRecipe in project PneumaticCraft by MineMaarten.

the class TileEntityAssemblyIOUnit method findPickupLocation.

private boolean findPickupLocation() {
    if (shouldSleep())
        return false;
    ForgeDirection[] inventoryDir = null;
    if (isImportUnit()) {
        searchedItemStack = null;
        if (recipeList != null) {
            for (AssemblyRecipe recipe : recipeList) {
                inventoryDir = getInventoryDirectionForItem(recipe.getInput());
                if (inventoryDir != null) {
                    searchedItemStack = recipe.getInput();
                    break;
                }
            }
        }
    } else {
        inventoryDir = getPlatformDirection();
    }
    targetDirection = inventoryDir;
    if (targetDirection == null) {
        sleepBeforeNextSearch();
        return false;
    } else
        return true;
}
Also used : AssemblyRecipe(pneumaticCraft.api.recipe.AssemblyRecipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection)

Aggregations

AssemblyRecipe (pneumaticCraft.api.recipe.AssemblyRecipe)4 ItemStack (net.minecraft.item.ItemStack)3 PositionedStack (codechicken.nei.PositionedStack)1 LocatedStack (igwmod.gui.LocatedStack)1 LocatedString (igwmod.gui.LocatedString)1 LocatedTexture (igwmod.gui.LocatedTexture)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 ItemAssemblyProgram (pneumaticCraft.common.item.ItemAssemblyProgram)1 AssemblyProgram (pneumaticCraft.common.recipes.programs.AssemblyProgram)1