Search in sources :

Example 1 with RedwireType

use of com.bluepowermod.api.wire.redstone.RedwireType 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 RedwireType

use of com.bluepowermod.api.wire.redstone.RedwireType in project BluePower by Qmunity.

the class OreDictionarySetup method init.

public static void init() {
    // Ores
    OreDictionary.registerOre(BPOredictNames.ORE_COPPER, BPBlocks.copper_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_ZINC, BPBlocks.zinc_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_SILVER, BPBlocks.silver_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_TUNGSTEN, BPBlocks.tungsten_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_TESLATITE, BPBlocks.teslatite_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_AMETHYST, BPBlocks.amethyst_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_RUBY, BPBlocks.ruby_ore);
    OreDictionary.registerOre(BPOredictNames.ORE_SAPPHIRE, BPBlocks.sapphire_ore);
    // Storage blocks
    OreDictionary.registerOre(BPOredictNames.BLOCK_COPPER, BPBlocks.copper_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_ZINC, BPBlocks.zinc_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_SILVER, BPBlocks.silver_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_TUNGSTEN, BPBlocks.tungsten_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_TESLATITE, BPBlocks.teslatite_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_AMETHYST, BPBlocks.amethyst_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_RUBY, BPBlocks.ruby_block);
    OreDictionary.registerOre(BPOredictNames.BLOCK_SAPPHIRE, BPBlocks.sapphire_block);
    // Ingots
    OreDictionary.registerOre(BPOredictNames.INGOT_COPPER, BPItems.copper_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_ZINC, BPItems.zinc_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_SILVER, BPItems.silver_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_TUNGSTEN, BPItems.tungsten_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_BLUE_ALLOY, BPItems.blue_alloy_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_RED_ALLOY, BPItems.red_alloy_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_PURPLE_ALLOY, BPItems.purple_alloy_ingot);
    OreDictionary.registerOre(BPOredictNames.INGOT_BRASS, BPItems.brass_ingot);
    // Dusts
    OreDictionary.registerOre(BPOredictNames.DUST_TESLATITE, BPItems.teslatite_dust);
    OreDictionary.registerOre(BPOredictNames.DUST_INFUSED_TESLATITE, BPItems.infused_teslatite_dust);
    OreDictionary.registerOre(BPOredictNames.DUST_ZINC, BPItems.zinc_dust);
    // Nuggets
    OreDictionary.registerOre("nuggetTungsten", BPItems.tungsten_nugget);
    // Gems
    OreDictionary.registerOre(BPOredictNames.GEM_AMETHYST, BPItems.amethyst_gem);
    OreDictionary.registerOre(BPOredictNames.GEM_RUBY, BPItems.ruby_gem);
    OreDictionary.registerOre(BPOredictNames.GEM_SAPPHIRE, BPItems.sapphire_gem);
    // Dyes
    OreDictionary.registerOre(BPOredictNames.DYE_INDIGO, BPItems.indigo_dye);
    // Circuitry
    OreDictionary.registerOre(BPOredictNames.STONE_TILE, BPItems.stone_tile);
    OreDictionary.registerOre(BPOredictNames.BLUESTONE_TILE, BPItems.bluestone_wire_tile);
    OreDictionary.registerOre(BPOredictNames.BLUESTONE_ANODE, BPItems.bluestone_anode_tile);
    OreDictionary.registerOre(BPOredictNames.BLUESTONE_CATHODE, BPItems.bluestone_cathode_tile);
    OreDictionary.registerOre(BPOredictNames.BLUESTONE_POINTER, BPItems.bluestone_pointer_tile);
    OreDictionary.registerOre(BPOredictNames.REDSTONE_TILE, BPItems.redstone_wire_tile);
    OreDictionary.registerOre(BPOredictNames.REDSTONE_ANODE, BPItems.redstone_anode_tile);
    OreDictionary.registerOre(BPOredictNames.REDSTONE_CATHODE, BPItems.redstone_cathode_tile);
    OreDictionary.registerOre(BPOredictNames.REDSTONE_POINTER, BPItems.redstone_pointer_tile);
    OreDictionary.registerOre(BPOredictNames.SILICON_CHIP, BPItems.silicon_chip_tile);
    OreDictionary.registerOre(BPOredictNames.TAINTED_SILICON_CHIP, BPItems.tainted_silicon_chip_tile);
    OreDictionary.registerOre(BPOredictNames.QUARTZ_RESONATOR, BPItems.quartz_resonator_tile);
    OreDictionary.registerOre(BPOredictNames.BUNDLED_TILE, BPItems.stone_bundle);
    // Other
    OreDictionary.registerOre(BPOredictNames.MARBLE, BPBlocks.marble);
    OreDictionary.registerOre(BPOredictNames.BASALT, BPBlocks.basalt);
    for (Block b : BPBlocks.blockLamp) OreDictionary.registerOre("lampBP", b);
    for (Block b : BPBlocks.blockLampInverted) OreDictionary.registerOre("lampInvertedBP", b);
    for (RedwireType t : RedwireType.values()) {
        for (MinecraftColor c : MinecraftColor.VALID_COLORS) {
            ItemStack wireInsulated = PartManager.getPartInfo("wire." + t.getName() + "." + c.name().toLowerCase()).getStack(1);
            OreDictionary.registerOre(String.format(BPOredictNames.WIRE_INSULATED_, t.getName()), wireInsulated.getItem());
            OreDictionary.registerOre(BPOredictNames.WIRE_INSULATED, wireInsulated.getItem());
            ItemStack wireBundled = PartManager.getPartInfo("wire." + t.getName() + ".bundled." + c.name().toLowerCase()).getStack(1);
            OreDictionary.registerOre(String.format(BPOredictNames.WIRE_BUNDLED_, t.getName()), wireBundled.getItem());
            OreDictionary.registerOre(BPOredictNames.WIRE_BUNDLED, wireBundled.getItem());
        }
        ItemStack wireBundled = PartManager.getPartInfo("wire." + t.getName() + ".bundled").getStack(1);
        OreDictionary.registerOre(String.format(BPOredictNames.WIRE_BUNDLED_, t.getName()), wireBundled.getItem());
        OreDictionary.registerOre(BPOredictNames.WIRE_BUNDLED, wireBundled.getItem());
    }
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) MinecraftColor(com.bluepowermod.api.misc.MinecraftColor) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 3 with RedwireType

use of com.bluepowermod.api.wire.redstone.RedwireType in project BluePower by Qmunity.

the class PartManager method registerParts.

public static void registerParts() {
    PartRegistry.registerFactory(new PartFactory());
    // Digital gates
    registerPart(GateAnd.class);
    registerPart(GateNot.class);
    registerPart(GateOr.class);
    registerPart(GateNand.class);
    registerPart(GateBuffer.class);
    registerPart(GateXor.class);
    registerPart(GateXnor.class);
    registerPart(GateNor.class);
    registerPart(GateTimer.class);
    registerPart(GateSequencer.class);
    registerPart(GateCounter.class);
    registerPart(GateMultiplexer.class);
    registerPart(GatePulseFormer.class);
    registerPart(GateRandomizer.class);
    registerPart(GateToggleLatch.class);
    registerPart(GateRSLatch.class);
    registerPart(GateStateCell.class);
    registerPart(GateRepeater.class);
    registerPart(GateTransparentLatch.class);
    registerPart(GateSynchronizer.class);
    // Analogue gates
    registerPart(GateInverter.class);
    registerPart(GateComparator.class);
    registerPart(GateLightCell.class);
    registerPart(GateRegulableTorch.class);
    // Wireless gates
    registerPart(GateTransceiver.class, false, false);
    registerPart(GateTransceiver.class, true, false);
    registerPart(GateTransceiver.class, false, true);
    registerPart(GateTransceiver.class, true, true);
    // IC's
    registerPart(GateIntegratedCircuit.class, 3);
    registerPart(GateIntegratedCircuit.class, 5);
    registerPart(GateIntegratedCircuit.class, 7);
    // Supported gates
    registerPart(GateNullCell.class);
    // Lamps
    for (int i = 0; i < 2; i++) for (MinecraftColor c : MinecraftColor.VALID_COLORS) registerPart(PartCageLamp.class, c, i == 1);
    for (int i = 0; i < 2; i++) for (MinecraftColor c : MinecraftColor.VALID_COLORS) registerPart(PartFixture.class, c, i == 1);
    // Pneumatic Tubes
    registerPart(PneumaticTube.class);
    registerPart(PneumaticTubeOpaque.class);
    registerPart(RestrictionTube.class);
    registerPart(RestrictionTubeOpaque.class);
    registerPart(MagTube.class);
    registerPart(Accelerator.class);
    // Wires
    for (RedwireType type : RedwireType.values()) {
        registerPart(PartRedwireFaceUninsulated.class, type);
        for (MinecraftColor color : MinecraftColor.VALID_COLORS) registerPart(PartRedwireFaceInsulated.class, type, color);
        registerPart(PartRedwireFaceBundled.class, type, MinecraftColor.NONE);
        for (MinecraftColor color : MinecraftColor.VALID_COLORS) registerPart(PartRedwireFaceBundled.class, type, color);
    }
    for (RedwireType type : RedwireType.values()) {
        registerPart(PartRedwireFreestandingUninsulated.class, type);
        for (MinecraftColor color : MinecraftColor.VALID_COLORS) registerPart(PartRedwireFreestandingInsulated.class, type, color);
        registerPart(PartRedwireFreestandingBundled.class, type, MinecraftColor.NONE);
        for (MinecraftColor color : MinecraftColor.VALID_COLORS) registerPart(PartRedwireFreestandingBundled.class, type, color);
    }
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) PartRedwireFreestandingInsulated(com.bluepowermod.part.wire.redstone.PartRedwireFreestanding.PartRedwireFreestandingInsulated) MinecraftColor(com.bluepowermod.api.misc.MinecraftColor) PartRedwireFaceInsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceInsulated) PartRedwireFreestandingBundled(com.bluepowermod.part.wire.redstone.PartRedwireFreestanding.PartRedwireFreestandingBundled) PartRedwireFaceBundled(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceBundled)

Example 4 with RedwireType

use of com.bluepowermod.api.wire.redstone.RedwireType in project BluePower by Qmunity.

the class GateNullCell method canConnect.

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice device, ConnectionType type) {
    if (type == ConnectionType.OPEN_CORNER && device instanceof IGate<?, ?, ?, ?, ?, ?>)
        return false;
    if (type == ConnectionType.STRAIGHT)
        if ((side == getFace().getOpposite() || side == ForgeDirection.UNKNOWN) && device instanceof DummyRedstoneDevice)
            return false;
    if (type == ConnectionType.CLOSED_CORNER) {
        if (side == getFace())
            return false;
        if (side == getFace().getOpposite())
            return false;
        if (side == ForgeDirection.UNKNOWN)
            return false;
    }
    if (device instanceof IRedwire) {
        RedwireType rwt = getRedwireType(side);
        if (rwt == null)
            return false;
        RedwireType rwt_ = ((IRedwire) device).getRedwireType(type == ConnectionType.STRAIGHT ? side.getOpposite() : (type == ConnectionType.CLOSED_CORNER ? getFace() : getFace().getOpposite()));
        if (rwt_ == null)
            return false;
        return rwt.canConnectTo(rwt_);
    }
    return true;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) IRedwire(com.bluepowermod.api.wire.redstone.IRedwire) DummyRedstoneDevice(com.bluepowermod.redstone.DummyRedstoneDevice)

Example 5 with RedwireType

use of com.bluepowermod.api.wire.redstone.RedwireType in project BluePower by Qmunity.

the class PneumaticTube method canConnect.

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice device, ConnectionType type) {
    if (type == ConnectionType.STRAIGHT) {
        if (getRedwireType(side) == null)
            return false;
        if (device instanceof IRedwire) {
            RedwireType rwt = getRedwireType(side);
            if (type == null)
                return false;
            RedwireType rwt_ = ((IRedwire) device).getRedwireType(type == ConnectionType.STRAIGHT ? side.getOpposite() : side.getOpposite());
            if (rwt_ == null)
                return false;
            if (!rwt.canConnectTo(rwt_))
                return false;
        }
        if (device instanceof IFace)
            return ((IFace) device).getFace() == side.getOpposite();
        if (!OcclusionHelper.microblockOcclusionTest(new Vec3i(this), MicroblockShape.FACE_HOLLOW, 8, side))
            return false;
        if (device instanceof PneumaticTube)
            if (device instanceof MagTube != this instanceof MagTube)
                return false;
        return true;
    }
    return false;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) Vec3i(uk.co.qmunity.lib.vec.Vec3i) IFace(com.bluepowermod.api.misc.IFace) IRedwire(com.bluepowermod.api.wire.redstone.IRedwire)

Aggregations

RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)9 GateNullCell (com.bluepowermod.part.gate.supported.GateNullCell)5 MinecraftColor (com.bluepowermod.api.misc.MinecraftColor)3 ItemStack (net.minecraft.item.ItemStack)3 IRedwire (com.bluepowermod.api.wire.redstone.IRedwire)2 ItemPart (com.bluepowermod.item.ItemPart)2 IFace (com.bluepowermod.api.misc.IFace)1 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)1 ItemScrewdriver (com.bluepowermod.item.ItemScrewdriver)1 PartRedwireFace (com.bluepowermod.part.wire.redstone.PartRedwireFace)1 PartRedwireFaceBundled (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceBundled)1 PartRedwireFaceInsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceInsulated)1 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)1 PartRedwireFreestandingBundled (com.bluepowermod.part.wire.redstone.PartRedwireFreestanding.PartRedwireFreestandingBundled)1 PartRedwireFreestandingInsulated (com.bluepowermod.part.wire.redstone.PartRedwireFreestanding.PartRedwireFreestandingInsulated)1 DummyRedstoneDevice (com.bluepowermod.redstone.DummyRedstoneDevice)1 Block (net.minecraft.block.Block)1 ShapedOreRecipe (net.minecraftforge.oredict.ShapedOreRecipe)1 ShapelessOreRecipe (net.minecraftforge.oredict.ShapelessOreRecipe)1 IPart (uk.co.qmunity.lib.part.IPart)1