Search in sources :

Example 1 with AssemblyProgram

use of pneumaticCraft.common.recipes.programs.AssemblyProgram in project PneumaticCraft by MineMaarten.

the class ItemAssemblyProgram method addInformation.

@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, EntityPlayer player, List infoList, boolean par4) {
    infoList.add("Required Machines:");
    infoList.add("-" + Blockss.assemblyController.getLocalizedName());
    if (referencePrograms == null) {
        referencePrograms = new AssemblyProgram[PROGRAMS_AMOUNT];
        for (int i = 0; i < PROGRAMS_AMOUNT; i++) {
            referencePrograms[i] = getProgramFromItem(i);
        }
    }
    AssemblyProgram program = referencePrograms[Math.min(stack.getItemDamage(), PROGRAMS_AMOUNT - 1)];
    AssemblyProgram.EnumMachine[] requiredMachines = program.getRequiredMachines();
    for (AssemblyProgram.EnumMachine machine : requiredMachines) {
        switch(machine) {
            case PLATFORM:
                infoList.add("-" + Blockss.assemblyPlatform.getLocalizedName());
                break;
            case DRILL:
                infoList.add("-" + Blockss.assemblyDrill.getLocalizedName());
                break;
            case LASER:
                infoList.add("-" + Blockss.assemblyLaser.getLocalizedName());
                break;
            case IO_UNIT_EXPORT:
                //TODO localize
                infoList.add("-" + Blockss.assemblyIOUnit.getLocalizedName() + " (export)");
                break;
            case IO_UNIT_IMPORT:
                infoList.add("-" + Blockss.assemblyIOUnit.getLocalizedName() + " (import)");
                break;
        }
    }
}
Also used : AssemblyProgram(pneumaticCraft.common.recipes.programs.AssemblyProgram) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 2 with AssemblyProgram

use of pneumaticCraft.common.recipes.programs.AssemblyProgram in project PneumaticCraft by MineMaarten.

the class TileEntityAssemblyController method updateEntity.

@Override
public void updateEntity() {
    if (!worldObj.isRemote && firstRun)
        updateConnections();
    // curProgram must be available on the client, or we can't show program-problems in the GUI
    if (curProgram == null && !goingToHomePosition && inventory[PROGRAM_INVENTORY_INDEX] != null && inventory[PROGRAM_INVENTORY_INDEX].getItem() == Itemss.assemblyProgram) {
        AssemblyProgram program = ItemAssemblyProgram.getProgramFromItem(inventory[PROGRAM_INVENTORY_INDEX].getItemDamage());
        curProgram = program;
    } else if (curProgram != null && (inventory[PROGRAM_INVENTORY_INDEX] == null || curProgram.getClass() != ItemAssemblyProgram.getProgramFromItem(inventory[PROGRAM_INVENTORY_INDEX].getItemDamage()).getClass())) {
        curProgram = null;
        if (!worldObj.isRemote)
            goingToHomePosition = true;
    }
    if (!worldObj.isRemote) {
        displayedText = "Standby";
        if (getPressure(ForgeDirection.UNKNOWN) >= PneumaticValues.MIN_PRESSURE_ASSEMBLY_CONTROLLER) {
            if (curProgram != null || goingToHomePosition) {
                List<IAssemblyMachine> machineList = getMachines();
                EnumMachine[] requiredMachines = curProgram != null ? curProgram.getRequiredMachines() : EnumMachine.values();
                TileEntityAssemblyDrill drill = null;
                TileEntityAssemblyLaser laser = null;
                TileEntityAssemblyIOUnit ioUnitImport = null;
                TileEntityAssemblyIOUnit ioUnitExport = null;
                TileEntityAssemblyPlatform platform = null;
                foundDuplicateMachine = false;
                boolean[] foundMachines = new boolean[requiredMachines.length];
                for (IAssemblyMachine machine : machineList) {
                    if (machine != this && machine instanceof TileEntityAssemblyController)
                        foundDuplicateMachine = true;
                    for (int i = 0; i < requiredMachines.length; i++) {
                        switch(requiredMachines[i]) {
                            case DRILL:
                                if (machine instanceof TileEntityAssemblyDrill) {
                                    if (drill != null)
                                        foundDuplicateMachine = true;
                                    drill = (TileEntityAssemblyDrill) machine;
                                    foundMachines[i] = true;
                                }
                                break;
                            case LASER:
                                if (machine instanceof TileEntityAssemblyLaser) {
                                    if (laser != null)
                                        foundDuplicateMachine = true;
                                    laser = (TileEntityAssemblyLaser) machine;
                                    foundMachines[i] = true;
                                }
                                break;
                            case IO_UNIT_IMPORT:
                                if (machine instanceof TileEntityAssemblyIOUnit && ((TileEntityAssemblyIOUnit) machine).getBlockMetadata() == 0) {
                                    if (ioUnitImport != null)
                                        foundDuplicateMachine = true;
                                    ioUnitImport = (TileEntityAssemblyIOUnit) machine;
                                    foundMachines[i] = true;
                                }
                                break;
                            case IO_UNIT_EXPORT:
                                if (machine instanceof TileEntityAssemblyIOUnit && ((TileEntityAssemblyIOUnit) machine).getBlockMetadata() == 1) {
                                    if (ioUnitExport != null)
                                        foundDuplicateMachine = true;
                                    ioUnitExport = (TileEntityAssemblyIOUnit) machine;
                                    foundMachines[i] = true;
                                }
                                break;
                            case PLATFORM:
                                if (machine instanceof TileEntityAssemblyPlatform) {
                                    if (platform != null)
                                        foundDuplicateMachine = true;
                                    platform = (TileEntityAssemblyPlatform) machine;
                                    foundMachines[i] = true;
                                }
                                break;
                        }
                    }
                }
                foundAllMachines = true;
                for (boolean foundMachine : foundMachines) {
                    if (!foundMachine) {
                        foundAllMachines = false;
                        break;
                    }
                }
                if ((foundAllMachines || curProgram == null) && !foundDuplicateMachine) {
                    // if(firstRun || areAllMachinesDone(machineList)) {
                    boolean useAir;
                    if (curProgram != null) {
                        useAir = curProgram.executeStep(this, platform, ioUnitImport, ioUnitExport, drill, laser);
                        if (useAir)
                            displayedText = "Running...";
                    } else {
                        useAir = true;
                        goToHomePosition(platform, ioUnitImport, ioUnitExport, drill, laser);
                        displayedText = "Resetting...";
                    }
                    if (useAir)
                        addAir(-(int) (PneumaticValues.USAGE_ASSEMBLING * getSpeedUsageMultiplierFromUpgrades(getUpgradeSlots())), ForgeDirection.UNKNOWN);
                    float speedMultiplier = getSpeedMultiplierFromUpgrades(getUpgradeSlots());
                    for (IAssemblyMachine machine : machineList) {
                        machine.setSpeed(speedMultiplier);
                    }
                }
            }
        }
        hasProblem = hasProblem();
    }
    super.updateEntity();
}
Also used : AssemblyProgram(pneumaticCraft.common.recipes.programs.AssemblyProgram) ItemAssemblyProgram(pneumaticCraft.common.item.ItemAssemblyProgram) EnumMachine(pneumaticCraft.common.recipes.programs.AssemblyProgram.EnumMachine)

Example 3 with AssemblyProgram

use of pneumaticCraft.common.recipes.programs.AssemblyProgram 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 AssemblyProgram

use of pneumaticCraft.common.recipes.programs.AssemblyProgram in project PneumaticCraft by MineMaarten.

the class NEIAssemblyControllerRecipeManager method loadUsageRecipes.

@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (int i = 0; i < ItemAssemblyProgram.PROGRAMS_AMOUNT; i++) {
        AssemblyProgram program = ItemAssemblyProgram.getProgramFromItem(i);
        boolean[] addedRecipe = new boolean[program.getRecipeList().size()];
        for (int j = 0; j < program.getRecipeList().size(); j++) {
            if (NEIClientUtils.areStacksSameTypeCrafting(program.getRecipeList().get(j).getInput(), ingredient)) {
                arecipes.add(getShape(i, j));
                addedRecipe[j] = true;
            }
        }
        if (ingredient.getItem() == Itemss.assemblyProgram && ingredient.getItemDamage() == i) {
            for (int j = 0; j < program.getRecipeList().size(); j++) if (!addedRecipe[j])
                arecipes.add(getShape(i, j));
        } else {
            for (ItemStack machine : getMachinesFromEnum(program.getRequiredMachines())) {
                if (NEIClientUtils.areStacksSameTypeCrafting(machine, ingredient)) {
                    for (int j = 0; j < program.getRecipeList().size(); j++) if (!addedRecipe[j])
                        arecipes.add(getShape(i, j));
                    break;
                }
            }
        }
    }
}
Also used : AssemblyProgram(pneumaticCraft.common.recipes.programs.AssemblyProgram) ItemAssemblyProgram(pneumaticCraft.common.item.ItemAssemblyProgram) ItemStack(net.minecraft.item.ItemStack)

Aggregations

AssemblyProgram (pneumaticCraft.common.recipes.programs.AssemblyProgram)4 ItemAssemblyProgram (pneumaticCraft.common.item.ItemAssemblyProgram)3 ItemStack (net.minecraft.item.ItemStack)2 PositionedStack (codechicken.nei.PositionedStack)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 AssemblyRecipe (pneumaticCraft.api.recipe.AssemblyRecipe)1 EnumMachine (pneumaticCraft.common.recipes.programs.AssemblyProgram.EnumMachine)1