Search in sources :

Example 1 with GateNullCell

use of com.bluepowermod.part.gate.supported.GateNullCell in project BluePower by Qmunity.

the class NullCellHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(ItemStack result) {
    if (result == null || !(result.getItem() instanceof ItemPart))
        return;
    try {
        for (int i = 0; i < 4; i++) {
            GateNullCell base = new GateNullCell(null, false, null, false);
            for (int j = 0; j < (i == 0 || i == 3 ? 1 : RedwireType.values().length); j++) {
                if (i == 1 || i == 2)
                    base = new GateNullCell(i == 1 ? RedwireType.values()[j] : null, false, i == 2 ? RedwireType.values()[j] : null, false);
                if (i < 3) {
                    for (RedwireType t1 : RedwireType.values()) {
                        for (RedwireType t2 : RedwireType.values()) {
                            NullCellRecipe r = new NullCellRecipe(base, t1, false, t2, false);
                            if (r.getResult() != null && ((ItemPart) r.getResult().item.getItem()).createPart(r.getResult().item, BluePower.proxy.getPlayer(), null, null).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                                arecipes.add(r);
                        }
                        NullCellRecipe r = new NullCellRecipe(base, t1, false, null, false);
                        if (r.getResult() != null && ((ItemPart) r.getResult().item.getItem()).createPart(r.getResult().item, BluePower.proxy.getPlayer(), null, null).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, null, false, t1, false);
                        if (r.getResult() != null && ((ItemPart) r.getResult().item.getItem()).createPart(r.getResult().item, BluePower.proxy.getPlayer(), null, null).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                    }
                } else {
                    for (RedwireType t1 : RedwireType.values()) {
                        for (RedwireType t2 : RedwireType.values()) {
                            base = new GateNullCell(t1, false, t2, false);
                            NullCellRecipe r = new NullCellRecipe(base, true, false);
                            if (r.getResult() != null && new GateNullCell(null, false, base.getTypeB(), base.isBundledB()).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                                arecipes.add(r);
                            r = new NullCellRecipe(base, true, true);
                            if (r.getResult() != null && new GateNullCell(null, false, null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                                arecipes.add(r);
                            r = new NullCellRecipe(base, false, true);
                            if (r.getResult() != null && new GateNullCell(base.getTypeB(), base.isBundledB(), null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                                arecipes.add(r);
                        }
                        base = new GateNullCell(t1, false, null, false);
                        NullCellRecipe r = new NullCellRecipe(base, true, false);
                        if (r.getResult() != null && new GateNullCell(null, false, base.getTypeB(), base.isBundledB()).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, true, true);
                        if (r.getResult() != null && new GateNullCell(null, false, null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, false, true);
                        if (r.getResult() != null && new GateNullCell(base.getTypeB(), base.isBundledB(), null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        base = new GateNullCell(null, false, t1, false);
                        r = new NullCellRecipe(base, true, false);
                        if (r.getResult() != null && new GateNullCell(null, false, base.getTypeB(), base.isBundledB()).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, true, true);
                        if (r.getResult() != null && new GateNullCell(null, false, null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, false, true);
                        if (r.getResult() != null && new GateNullCell(base.getTypeB(), base.isBundledB(), null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                            arecipes.add(r);
                    }
                    NullCellRecipe r = new NullCellRecipe(base, true, false);
                    if (r.getResult() != null && new GateNullCell(null, false, base.getTypeB(), base.isBundledB()).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                        arecipes.add(r);
                    r = new NullCellRecipe(base, true, true);
                    if (r.getResult() != null && new GateNullCell(null, false, null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                        arecipes.add(r);
                    r = new NullCellRecipe(base, false, true);
                    if (r.getResult() != null && new GateNullCell(base.getTypeB(), base.isBundledB(), null, false).equals(((ItemPart) result.getItem()).createPart(result, BluePower.proxy.getPlayer(), null, null)))
                        arecipes.add(r);
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) ItemPart(com.bluepowermod.item.ItemPart) GateNullCell(com.bluepowermod.part.gate.supported.GateNullCell)

Example 2 with GateNullCell

use of com.bluepowermod.part.gate.supported.GateNullCell in project BluePower by Qmunity.

the class NullCellHandler method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals(getRecipesID())) {
        try {
            for (int i = 0; i < 4; i++) {
                GateNullCell base = new GateNullCell(null, false, null, false);
                for (int j = 0; j < (i == 0 || i == 3 ? 1 : RedwireType.values().length); j++) {
                    if (i == 1 || i == 2)
                        base = new GateNullCell(i == 1 ? RedwireType.values()[j] : null, false, i == 2 ? RedwireType.values()[j] : null, false);
                    if (i < 3) {
                        for (RedwireType t1 : RedwireType.values()) {
                            for (RedwireType t2 : RedwireType.values()) {
                                NullCellRecipe r = new NullCellRecipe(base, t1, false, t2, false);
                                if (r.getResult() != null)
                                    arecipes.add(r);
                            }
                            NullCellRecipe r = new NullCellRecipe(base, t1, false, null, false);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            r = new NullCellRecipe(base, null, false, t1, false);
                            if (r.getResult() != null)
                                arecipes.add(r);
                        }
                    } else {
                        for (RedwireType t1 : RedwireType.values()) {
                            for (RedwireType t2 : RedwireType.values()) {
                                base = new GateNullCell(t1, false, t2, false);
                                NullCellRecipe r = new NullCellRecipe(base, true, false);
                                if (r.getResult() != null)
                                    arecipes.add(r);
                                r = new NullCellRecipe(base, true, true);
                                if (r.getResult() != null)
                                    arecipes.add(r);
                                r = new NullCellRecipe(base, false, true);
                                if (r.getResult() != null)
                                    arecipes.add(r);
                            }
                            base = new GateNullCell(t1, false, null, false);
                            NullCellRecipe r = new NullCellRecipe(base, true, false);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            r = new NullCellRecipe(base, true, true);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            r = new NullCellRecipe(base, false, true);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            base = new GateNullCell(null, false, t1, false);
                            r = new NullCellRecipe(base, true, false);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            r = new NullCellRecipe(base, true, true);
                            if (r.getResult() != null)
                                arecipes.add(r);
                            r = new NullCellRecipe(base, false, true);
                            if (r.getResult() != null)
                                arecipes.add(r);
                        }
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return;
    }
    super.loadCraftingRecipes(outputId, results);
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) GateNullCell(com.bluepowermod.part.gate.supported.GateNullCell)

Example 3 with GateNullCell

use of com.bluepowermod.part.gate.supported.GateNullCell in project BluePower by Qmunity.

the class NullCellHandler method loadUsageRecipes.

@Override
public void loadUsageRecipes(ItemStack ingredient) {
    try {
        for (int i = 0; i < 4; i++) {
            GateNullCell base = new GateNullCell(null, false, null, false);
            for (int j = 0; j < (i == 0 || i == 3 ? 1 : RedwireType.values().length); j++) {
                if (i == 1 || i == 2)
                    base = new GateNullCell(i == 1 ? RedwireType.values()[j] : null, false, i == 2 ? RedwireType.values()[j] : null, false);
                if (i < 3) {
                    for (RedwireType t1 : RedwireType.values()) {
                        for (RedwireType t2 : RedwireType.values()) {
                            NullCellRecipe r = new NullCellRecipe(base, t1, false, t2, false);
                            if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                                arecipes.add(r);
                        }
                        NullCellRecipe r = new NullCellRecipe(base, t1, false, null, false);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, null, false, t1, false);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                    }
                } else {
                    for (RedwireType t1 : RedwireType.values()) {
                        for (RedwireType t2 : RedwireType.values()) {
                            base = new GateNullCell(t1, false, t2, false);
                            NullCellRecipe r = new NullCellRecipe(base, true, false);
                            if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                                arecipes.add(r);
                            r = new NullCellRecipe(base, true, true);
                            if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                                arecipes.add(r);
                            r = new NullCellRecipe(base, false, true);
                            if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                                arecipes.add(r);
                        }
                        base = new GateNullCell(t1, false, null, false);
                        NullCellRecipe r = new NullCellRecipe(base, true, false);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, true, true);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, false, true);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        base = new GateNullCell(null, false, t1, false);
                        r = new NullCellRecipe(base, true, false);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, true, true);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                        r = new NullCellRecipe(base, false, true);
                        if (r.getResult() != null && r.contains(r.ingredients, ingredient))
                            arecipes.add(r);
                    }
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) GateNullCell(com.bluepowermod.part.gate.supported.GateNullCell)

Example 4 with GateNullCell

use of com.bluepowermod.part.gate.supported.GateNullCell in project BluePower by Qmunity.

the class LogicRecipes method init.

public static void init() {
    // Components
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_wire_tile, 1), "#", "W", '#', "dustTeslatite", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_anode_tile, 3), " # ", "###", "WWW", '#', "dustTeslatite", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_cathode_tile, 1), "T#T", " W ", 'T', "dustTeslatite", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_pointer_tile, 1), " S ", "T#T", " W ", 'S', "stone", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE, 'T', "dustTeslatite"));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.bluestone_pointer_tile, 1), "S", "T", 'S', "stone", 'T', BPOredictNames.BLUESTONE_CATHODE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_wire_tile, 1), "#", "W", '#', "dustRedstone", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_anode_tile, 3), " # ", "###", "WWW", '#', "dustRedstone", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_cathode_tile, 1), "#", "W", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_pointer_tile, 1), "S", "#", "W", 'S', "stone", '#', Blocks.redstone_torch, 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.redstone_pointer_tile, 1), "S", "T", 'S', "stone", 'T', BPOredictNames.REDSTONE_CATHODE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.silicon_chip_tile, 1), " # ", "WWW", '#', BPItems.blue_doped_wafer, 'W', BPOredictNames.STONE_TILE));
    // GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.plate_assembly, 1), " # ", "SRS", "#C#", '#', BPOredictNames.STONE_TILE,
    // 'S',
    // "stickWood", 'R', BPItems.red_alloy_ingot, 'C', BPItems.stone_cathode)));
    GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(BPItems.tainted_silicon_chip_tile, 1), BPOredictNames.SILICON_CHIP, Items.glowstone_dust));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.quartz_resonator_tile, 3), " # ", "###", "WWW", '#', "gemQuartz", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.stone_bundle, 1), "#", "W", '#', "wireBundled", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(BPItems.infused_teslatite_dust, 1), BPOredictNames.DUST_TESLATITE, Items.redstone));
    {
        for (RedwireType t : RedwireType.values()) {
            int i = 0;
            for (MinecraftColor c : MinecraftColor.WIRE_COLORS) {
                ItemStack stack = PartManager.getPartInfo("wire." + t.getName() + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase())).getStack(12);
                ItemStack freestanding = PartManager.getPartInfo("wire.freestanding." + t.getName() + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase())).getStack(1);
                if (c == MinecraftColor.NONE) {
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "iii", 'i', t.getIngotOredictName()));
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "i", "i", "i", 'i', t.getIngotOredictName()));
                } else {
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "www", "iii", "www", 'i', t.getIngotOredictName(), 'w', new ItemStack(Blocks.wool, 1, i)));
                    GameRegistry.addRecipe(new ShapedOreRecipe(stack.copy(), "wiw", "wiw", "wiw", 'i', t.getIngotOredictName(), 'w', new ItemStack(Blocks.wool, 1, i)));
                }
                GameRegistry.addRecipe(new ShapedOreRecipe(freestanding, " s ", "sws", " s ", 's', "stickWood", 'w', stack.copy()));
                i++;
            }
        }
    }
    for (RedwireType t : RedwireType.values()) {
        ItemStack bundled = PartManager.getPartInfo("wire." + t.getName() + ".bundled").getStack(1);
        ItemStack freestanding = PartManager.getPartInfo("wire.freestanding." + t.getName() + ".bundled").getStack(1);
        GameRegistry.addRecipe(new ShapedOreRecipe(bundled, "sws", "www", "sws", 'w', t.getName() + "Insulated", 's', Items.string));
        GameRegistry.addRecipe(new ShapedOreRecipe(freestanding, " s ", "sws", " s ", 's', "stickWood", 'w', bundled.copy()));
        for (MinecraftColor c : MinecraftColor.VALID_COLORS) {
            ItemStack stack = PartManager.getPartInfo("wire." + t.getName() + ".bundled" + (c == MinecraftColor.NONE ? "" : "." + c.name().toLowerCase())).getStack(8);
            GameRegistry.addRecipe(new ShapedOreRecipe(stack, "www", "wdw", "www", 'w', bundled, 'd', "dye" + StringUtils.capitalize(ItemDye.field_150923_a[15 - c.ordinal()])));
        }
    }
    // Blocks
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPBlocks.circuit_table), "WIW", "WCW", "WPW", 'W', "plankWood", 'I', PartManager.getPartInfo("integratedCircuit3x3").getStack(), 'C', Blocks.chest, 'P', BPBlocks.project_table));
    // Gates and Circuits
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("and").getStack(), "ACA", "CCC", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("buffer").getStack(), "ACA", "WCW", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("bustransceiver"), "BBB", "N#N", "BBB", '#', BPOredictNames.STONE_TILE,
    // 'B',
    // BPItems.stone_bundle, 'N', BPItems.red_doped_wafer));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("counter").getStack(), "#W#", "CPC", "#W#", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE, 'P', BPOredictNames.BLUESTONE_POINTER));
    // craftManager.addRecipe(PartManager.getPartInfo("invert"), "#R#", "ROR", "#R#", '#', BPOredictNames.STONE_TILE, 'O',
    // BPItems.plate_assembly, 'R', BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("lightCell").getStack(), "#W#", "#B#", "###", '#', BPOredictNames.STONE_TILE, 'B', BPItems.blue_doped_wafer, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("multiplexer").getStack(), "ACA", "C#C", "ACW", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("nand").getStack(), "AAA", "CCC", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(PartManager.getPartInfo("noninvert"), "#R#", "ROR", "#RC", '#', BPOredictNames.STONE_TILE, 'C',
    // BPItems.stone_cathode, 'O', BPItems.plate_assembly, 'R', BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("nor").getStack(), "#A#", "WCW", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("not").getStack(), "#A#", "ACA", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    // craftManager.addRecipe(PartManager.getPartInfo("null"), "#R#", "RRR", "#R#", '#', BPOredictNames.STONE_TILE, 'R',
    // BPItems.stone_redwire));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("or").getStack(), "#C#", "WCW", "#W#", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("randomizer").getStack(), "#T#", "WWW", "TWT", '#', BPOredictNames.STONE_TILE, 'T', BPOredictNames.TAINTED_SILICON_CHIP, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("pulseformer").getStack(), "ACA", "CAC", "WW#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("repeater").getStack(), "#CW", "#AW", "#WC", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("rs").getStack(), "WWA", "C#C", "AWW", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("sequencer").getStack(), "#C#", "CPC", "#C#", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'P', BPOredictNames.BLUESTONE_POINTER));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("state").getStack(), "#AC", "WXP", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'P', BPOredictNames.BLUESTONE_POINTER, 'W', BPOredictNames.BLUESTONE_TILE, 'X', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("synchronizer").getStack(), "WCW", "XAX", "WWW", 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE, 'X', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("timer").getStack(), "#W#", "WPW", "ACA", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE, 'P', BPOredictNames.BLUESTONE_POINTER));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("toggle").getStack(), "C##", "WLW", "C##", '#', BPOredictNames.STONE_TILE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE, 'L', Blocks.lever));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("transparent").getStack(), "ACW", "CCC", "CW#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("xnor").getStack(), "ACA", "CAC", "WCW", 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("xor").getStack(), "AWA", "CAC", "WCW", 'A', BPOredictNames.BLUESTONE_ANODE, 'C', BPOredictNames.BLUESTONE_CATHODE, 'W', BPOredictNames.BLUESTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("comparator").getStack(), "TCT", "WRW", "CAC", 'A', BPOredictNames.REDSTONE_ANODE, 'C', BPOredictNames.REDSTONE_CATHODE, 'W', BPOredictNames.REDSTONE_TILE, 'T', BPOredictNames.STONE_TILE, 'R', BPOredictNames.QUARTZ_RESONATOR));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("inverter").getStack(), "#A#", "ACA", "#W#", '#', BPOredictNames.STONE_TILE, 'A', BPOredictNames.REDSTONE_ANODE, 'C', BPOredictNames.REDSTONE_CATHODE, 'W', BPOredictNames.REDSTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("regulabletorch").getStack(), "#W#", "#P#", "###", '#', BPOredictNames.STONE_TILE, 'P', BPOredictNames.REDSTONE_POINTER, 'W', BPOredictNames.REDSTONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(GateNullCell.getStackWithData(new GateNullCell()), "SSS", "S S", "WWW", 'S', "stickWood", 'W', BPOredictNames.STONE_TILE));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit3x3").getStack(), "TST", "SSS", "TST", 'T', BPOredictNames.STONE_TILE, 'S', BPOredictNames.SILICON_CHIP));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit5x5").getStack(), "II", "II", 'I', PartManager.getPartInfo("integratedCircuit3x3").getStack()));
    GameRegistry.addRecipe(new ShapedOreRecipe(PartManager.getPartInfo("integratedCircuit7x7").getStack(), "II", "II", 'I', PartManager.getPartInfo("integratedCircuit5x5").getStack()));
    GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPBlocks.circuit_database, 1), "#C#", "BTB", "###", '#', "ingotIron", 'C', PartManager.getPartInfo("integratedCircuit7x7").getStack(), 'B', Blocks.bookshelf, 'T', BPBlocks.circuit_table));
    // Custom crafting for nullcells
    GameRegistry.addRecipe(RecipeNullCell.instance);
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) MinecraftColor(com.bluepowermod.api.misc.MinecraftColor) GateNullCell(com.bluepowermod.part.gate.supported.GateNullCell) ShapedOreRecipe(net.minecraftforge.oredict.ShapedOreRecipe) ShapelessOreRecipe(net.minecraftforge.oredict.ShapelessOreRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 5 with GateNullCell

use of com.bluepowermod.part.gate.supported.GateNullCell in project BluePower by Qmunity.

the class RecipeNullCell method getCraftingResult.

private ItemStack getCraftingResult(IInventory inv, EntityPlayer player, boolean isCrafting) {
    if (inv.getSizeInventory() < 9)
        return null;
    int centerX = 0;
    int centerY = 0;
    GateNullCell gnc = null;
    // Find the null cell
    for (int x = 0; x < 3; x++) {
        for (int y = 0; y < 3; y++) {
            ItemStack item = getItemAt(inv, x, y);
            if (item == null)
                continue;
            if (!(item.getItem() instanceof ItemPart))
                continue;
            IPart p = ((ItemPart) item.getItem()).createPart(item, BluePower.proxy.getPlayer(), null, null);
            if (p != null && p instanceof GateNullCell) {
                gnc = (GateNullCell) p;
                centerX = x;
                centerY = y;
                break;
            }
        }
        if (gnc != null)
            break;
    }
    // If there's no null cell, return null
    if (gnc == null)
        return null;
    // Make this recipe invalid if there's items where there shouldn't be
    {
        // To the right
        if (centerX < 2)
            for (int x = centerX + 1; x < 3; x++) for (int y = 0; y < 3; y++) if (getItemAt(inv, x, y) != null)
                return null;
        // To the left - 1
        for (int x = 0; x < centerX - 1; x++) for (int y = 0; y < 3; y++) if (getItemAt(inv, x, y) != null)
            return null;
        // To the left
        if (centerX > 0) {
            if (getItemAt(inv, centerX - 1, 0) != null)
                return null;
            if (getItemAt(inv, centerX - 1, 2) != null)
                return null;
        }
    }
    // Determine what kind of crafting operation this is
    // Removing > adding
    {
        // Removing
        {
            // Screwdriver on top
            if (centerY > 0) {
                ItemStack sd = getItemAt(inv, centerX, centerY - 1);
                if (sd != null && sd.getItem() instanceof ItemScrewdriver) {
                    RedwireType t = gnc.getTypeB();
                    boolean bundled = gnc.isBundledB();
                    if (t != null) {
                        boolean can = true;
                        if (centerY < 2)
                            if (getItemAt(inv, centerX, centerY + 1) != null)
                                can = false;
                        if (centerX > 0)
                            if (getItemAt(inv, centerX - 1, centerY) != null)
                                can = false;
                        if (!((IScrewdriver) sd.getItem()).damage(sd, getItemAt(inv, centerX, centerY).stackSize, null, true))
                            can = false;
                        if (can) {
                            ItemStack wire = PartManager.getPartInfo("wire." + t.getName() + (bundled ? ".bundled" : "")).getStack(getItemAt(inv, centerX, centerY).stackSize);
                            if (isCrafting) {
                                gnc = new GateNullCell(gnc.getTypeA(), gnc.isBundledA(), null, false);
                                ItemStack nullCellStack = GateNullCell.getStackWithData(gnc);
                                nullCellStack.stackSize = getItemAt(inv, centerX, centerY).stackSize + 1;
                                setItemAt(inv, centerX, centerY, nullCellStack);
                                sd.stackSize++;
                                ((IScrewdriver) sd.getItem()).damage(sd, nullCellStack.stackSize - 1, null, false);
                            }
                            return wire;
                        }
                    }
                }
            }
            // Screwdriver below
            if (centerY < 2) {
                ItemStack sd = getItemAt(inv, centerX, centerY + 1);
                if (sd != null && sd.getItem() instanceof ItemScrewdriver) {
                    RedwireType t = gnc.getTypeA();
                    boolean bundled = gnc.isBundledA();
                    if (t != null) {
                        boolean can = true;
                        if (centerY > 0)
                            if (getItemAt(inv, centerX, centerY - 1) != null)
                                can = false;
                        if (centerX > 0)
                            if (getItemAt(inv, centerX - 1, centerY) != null)
                                can = false;
                        if (!((IScrewdriver) sd.getItem()).damage(sd, getItemAt(inv, centerX, centerY).stackSize, null, true))
                            can = false;
                        if (can) {
                            ItemStack wire = PartManager.getPartInfo("wire." + t.getName() + (bundled ? ".bundled" : "")).getStack(getItemAt(inv, centerX, centerY).stackSize);
                            if (isCrafting) {
                                gnc = new GateNullCell(null, false, gnc.getTypeB(), gnc.isBundledB());
                                ItemStack nullCellStack = GateNullCell.getStackWithData(gnc);
                                nullCellStack.stackSize = getItemAt(inv, centerX, centerY).stackSize + 1;
                                setItemAt(inv, centerX, centerY, nullCellStack);
                                sd.stackSize++;
                                ((IScrewdriver) sd.getItem()).damage(sd, nullCellStack.stackSize - 1, null, false);
                            }
                            return wire;
                        }
                    }
                }
            }
            // Screwdriver on the left
            if (centerX > 0) {
                ItemStack sd = getItemAt(inv, centerX - 1, centerY);
                if (sd != null && sd.getItem() instanceof ItemScrewdriver) {
                    RedwireType tA = gnc.getTypeA();
                    boolean bundledA = gnc.isBundledA();
                    RedwireType tB = gnc.getTypeB();
                    boolean bundledB = gnc.isBundledB();
                    if (tA != null || tB != null) {
                        boolean can = true;
                        if (centerY > 0)
                            if (getItemAt(inv, centerX, centerY - 1) != null)
                                can = false;
                        if (centerY < 2)
                            if (getItemAt(inv, centerX, centerY + 1) != null)
                                can = false;
                        int amt = 0;
                        if (tA != null && (tB == null || tB == tA))
                            amt += getItemAt(inv, centerX, centerY).stackSize;
                        if (tB != null)
                            amt += getItemAt(inv, centerX, centerY).stackSize;
                        if (amt > 64)
                            can = false;
                        if (!((IScrewdriver) sd.getItem()).damage(sd, amt, null, true))
                            can = false;
                        if (can) {
                            ItemStack wire = null;
                            if (tB != null) {
                                wire = PartManager.getPartInfo("wire." + tB.getName() + (bundledB ? ".bundled" : "")).getStack(amt);
                            } else {
                                wire = PartManager.getPartInfo("wire." + tA.getName() + (bundledA ? ".bundled" : "")).getStack(amt);
                            }
                            if (isCrafting) {
                                if (tA != null && tB != null && tA == tB) {
                                    gnc = new GateNullCell(null, false, null, false);
                                } else if (tB != null) {
                                    gnc = new GateNullCell(gnc.getTypeA(), gnc.isBundledA(), null, false);
                                } else if (tA != null) {
                                    gnc = new GateNullCell(null, false, gnc.getTypeB(), gnc.isBundledB());
                                }
                                ItemStack nullCellStack = GateNullCell.getStackWithData(gnc);
                                nullCellStack.stackSize = getItemAt(inv, centerX, centerY).stackSize + 1;
                                setItemAt(inv, centerX, centerY, nullCellStack);
                                sd.stackSize++;
                                System.out.println(((IScrewdriver) sd.getItem()).damage(sd, amt, null, false) + " " + player);
                            }
                            return wire;
                        }
                    }
                }
            }
        }
        // Adding
        {
            // Wire on top
            if (centerY > 0 && gnc.getTypeB() == null) {
                ItemStack wire = getItemAt(inv, centerX, centerY - 1);
                if (wire != null && wire.getItem() instanceof ItemPart) {
                    IPart p = ((ItemPart) wire.getItem()).createPart(wire, BluePower.proxy.getPlayer(), null, null);
                    if (p != null && p instanceof PartRedwireFaceUninsulated) {
                        RedwireType t = ((PartRedwireFace) p).getRedwireType(ForgeDirection.UNKNOWN);
                        boolean bundled = false;
                        boolean can = true;
                        if (centerY < 2)
                            if (getItemAt(inv, centerX, centerY + 1) != null)
                                can = false;
                        if (centerX > 0)
                            if (getItemAt(inv, centerX - 1, centerY) != null)
                                can = false;
                        if (can)
                            return GateNullCell.getStackWithData(new GateNullCell(gnc.getTypeA(), gnc.isBundledA(), t, bundled));
                    }
                }
            }
            // Wire below
            if (centerY < 2 && gnc.getTypeA() == null) {
                ItemStack wire = getItemAt(inv, centerX, centerY + 1);
                if (wire != null && wire.getItem() instanceof ItemPart) {
                    IPart p = ((ItemPart) wire.getItem()).createPart(wire, BluePower.proxy.getPlayer(), null, null);
                    if (p != null && p instanceof PartRedwireFaceUninsulated) {
                        RedwireType t = ((PartRedwireFace) p).getRedwireType(ForgeDirection.UNKNOWN);
                        boolean bundled = false;
                        boolean can = true;
                        if (centerY > 0)
                            if (getItemAt(inv, centerX, centerY - 1) != null)
                                can = false;
                        if (centerX > 0)
                            if (getItemAt(inv, centerX - 1, centerY) != null)
                                can = false;
                        if (can)
                            return GateNullCell.getStackWithData(new GateNullCell(t, bundled, gnc.getTypeB(), gnc.isBundledB()));
                    }
                }
            }
            // Wire below
            if (centerY == 1 && gnc.getTypeA() == null && gnc.getTypeB() == null) {
                ItemStack wireA = getItemAt(inv, centerX, centerY + 1);
                ItemStack wireB = getItemAt(inv, centerX, centerY - 1);
                if (wireA != null && wireA.getItem() instanceof ItemPart && wireB != null && wireB.getItem() instanceof ItemPart) {
                    IPart pA = ((ItemPart) wireA.getItem()).createPart(wireA, BluePower.proxy.getPlayer(), null, null);
                    IPart pB = ((ItemPart) wireB.getItem()).createPart(wireB, BluePower.proxy.getPlayer(), null, null);
                    if (pA != null && pA instanceof PartRedwireFaceUninsulated && pB != null && pB instanceof PartRedwireFaceUninsulated) {
                        RedwireType tA = ((PartRedwireFace) pA).getRedwireType(ForgeDirection.UNKNOWN);
                        boolean bundledA = false;
                        RedwireType tB = ((PartRedwireFace) pB).getRedwireType(ForgeDirection.UNKNOWN);
                        boolean bundledB = false;
                        boolean can = true;
                        if (centerX > 0)
                            if (getItemAt(inv, centerX - 1, centerY) != null)
                                can = false;
                        if (can)
                            return GateNullCell.getStackWithData(new GateNullCell(tA, bundledA, tB, bundledB));
                    }
                }
            }
        }
    }
    return null;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) GateNullCell(com.bluepowermod.part.gate.supported.GateNullCell) ItemPart(com.bluepowermod.item.ItemPart) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) IPart(uk.co.qmunity.lib.part.IPart) PartRedwireFace(com.bluepowermod.part.wire.redstone.PartRedwireFace) ItemStack(net.minecraft.item.ItemStack) ItemScrewdriver(com.bluepowermod.item.ItemScrewdriver) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)

Aggregations

RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)5 GateNullCell (com.bluepowermod.part.gate.supported.GateNullCell)5 ItemPart (com.bluepowermod.item.ItemPart)2 ItemStack (net.minecraft.item.ItemStack)2 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1 MinecraftColor (com.bluepowermod.api.misc.MinecraftColor)1 ItemScrewdriver (com.bluepowermod.item.ItemScrewdriver)1 PartRedwireFace (com.bluepowermod.part.wire.redstone.PartRedwireFace)1 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)1 ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)1 ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)1 IPart (uk.co.qmunity.lib.part.IPart)1