Search in sources :

Example 1 with PartRedwireFaceUninsulated

use of com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated in project BluePower by Qmunity.

the class GateNullCell method drawHighlight.

@Override
public boolean drawHighlight(QMovingObjectPosition mop, EntityPlayer player, float frame) {
    Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
    Vec3 pos = player.getPosition(frame);
    ItemStack held = player.getCurrentEquippedItem();
    if (held == null)
        return false;
    if (held.getItem() instanceof ItemPart) {
        IPart part = ((ItemPart) held.getItem()).createPart(held, player, null, null);
        if (part == null)
            return false;
        if (!(part instanceof PartRedwireFaceUninsulated))
            return false;
        PartRedwireFace wire = (PartRedwireFace) part;
        RenderHelper renderer = RenderHelper.instance;
        renderer.fullReset();
        renderer.setRenderCoords(getWorld(), getX(), getY(), getZ());
        double height = 2 / 16D;
        IIcon wireIcon = IconSupplier.wire;
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        Tessellator.instance.startDrawingQuads();
        Tessellator.instance.addTranslation((float) -pos.xCoord, (float) -pos.yCoord, (float) -pos.zCoord);
        {
            switch(getFace()) {
                case DOWN:
                    break;
                case UP:
                    renderer.addTransformation(new Rotation(180, 180, 0, Vec3d.center));
                    break;
                case NORTH:
                    renderer.addTransformation(new Rotation(90, 0, 0, Vec3d.center));
                    break;
                case SOUTH:
                    renderer.addTransformation(new Rotation(-90, 0, 0, Vec3d.center));
                    break;
                case WEST:
                    renderer.addTransformation(new Rotation(0, 0, -90, Vec3d.center));
                    break;
                case EAST:
                    renderer.addTransformation(new Rotation(0, 0, 90, Vec3d.center));
                    break;
                default:
                    break;
            }
            int rotation = getRotation();
            if (rotation != -1)
                renderer.addTransformation(new Rotation(0, 90 * -rotation, 0));
            renderer.setOpacity(0.5);
            renderer.setColor(WireHelper.getColorForPowerLevel(wire.getRedwireType(ForgeDirection.UNKNOWN), (byte) (255 / 2)));
            ForgeDirection dir = ForgeDirection.NORTH;
            if (getRotation() % 2 == 1)
                dir = dir.getRotation(getFace());
            if (hit.getY() > 2 / 16D) {
                if (typeB == null) {
                    renderer.renderBox(new Vec3dCube(0 / 16D, 2 / 16D, 7 / 16D, 2 / 16D, 10 / 16D, 9 / 16D), wireIcon);
                    renderer.renderBox(new Vec3dCube(14 / 16D, 2 / 16D, 7 / 16D, 16 / 16D, 10 / 16D, 9 / 16D), wireIcon);
                    renderer.renderBox(new Vec3dCube(0 / 16D, 10 / 16D, 7 / 16D, 16 / 16D, 12 / 16D, 9 / 16D), wireIcon);
                }
            } else {
                if (typeA == null)
                    renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 0 / 16D, 9 / 16D, 2 / 16D + height, 16 / 16D), wireIcon);
            }
            renderer.fullReset();
        }
        Tessellator.instance.addTranslation((float) pos.xCoord, (float) pos.yCoord, (float) pos.zCoord);
        Tessellator.instance.draw();
        GL11.glDisable(GL11.GL_BLEND);
        return true;
    } else if (held.getItem() instanceof IScrewdriver) {
    // List<Vec3dCube> l = new ArrayList<Vec3dCube>();
    // super.addBoxes(l);
    // boolean def = false;
    // for (Vec3dCube c : l)
    // if (mop.getCube().equals(c.clone().rotate(getFace(), Vec3d.center).rotate(0, 90 * -getRotation(), 0, Vec3d.center)))
    // def = true;
    // if (def || hit.getY() <= 2 / 16D) {
    // Vec3dCube c = Vec3dCube.merge(getSelectionBoxes()).expand(0.001);
    //
    // GL11.glEnable(GL11.GL_BLEND);
    // GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    // GL11.glDisable(GL11.GL_TEXTURE_2D);
    // GL11.glColor4f(0, 0, 0, 0.4F);
    // GL11.glLineWidth(2);
    // GL11.glDepthMask(true);
    // GL11.glPushMatrix();
    //
    // Tessellator var2 = Tessellator.instance;
    // var2.startDrawing(3);
    // Tessellator.instance.addTranslation((float) -pos.xCoord + getX(), (float) -pos.yCoord + getY(), (float) -pos.zCoord
    // + getZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.draw();
    // var2.startDrawing(3);
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.draw();
    // var2.startDrawing(1);
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMinZ());
    // var2.addVertex(c.getMaxX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMaxX(), c.getMaxY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMinY(), c.getMaxZ());
    // var2.addVertex(c.getMinX(), c.getMaxY(), c.getMaxZ());
    // Tessellator.instance.addTranslation((float) pos.xCoord - getX(), (float) pos.yCoord - getY(), (float) pos.zCoord - getZ());
    // var2.draw();
    //
    // GL11.glPopMatrix();
    // GL11.glDepthMask(false);
    // GL11.glEnable(GL11.GL_TEXTURE_2D);
    // GL11.glDisable(GL11.GL_BLEND);
    //
    // return true;
    // }
    //
    // return true;
    }
    return false;
}
Also used : ItemPart(com.bluepowermod.item.ItemPart) RenderHelper(uk.co.qmunity.lib.client.render.RenderHelper) IIcon(net.minecraft.util.IIcon) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3d(uk.co.qmunity.lib.vec.Vec3d) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) IPart(uk.co.qmunity.lib.part.IPart) Vec3(net.minecraft.util.Vec3) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) PartRedwireFace(com.bluepowermod.part.wire.redstone.PartRedwireFace) ItemStack(net.minecraft.item.ItemStack) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 2 with PartRedwireFaceUninsulated

use of com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated in project BluePower by Qmunity.

the class PneumaticTube method onActivated.

/**
     * Event called when the part is activated (right clicked)
     *
     * @param player
     *            Player that right clicked the part
     * @param item
     *            Item that was used to click it
     * @return Whether or not an action occurred
     */
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
    if (getWorld() == null)
        return false;
    if (item != null) {
        TubeColor newColor = null;
        if (item.getItem() == BPItems.paint_brush && ((ItemDamageableColorableOverlay) BPItems.paint_brush).tryUseItem(item)) {
            newColor = TubeColor.values()[item.getItemDamage()];
        } else if (item.getItem() == Items.water_bucket || (item.getItem() == BPItems.paint_brush && item.getItemDamage() == 16)) {
            newColor = TubeColor.NONE;
        }
        if (newColor != null) {
            if (!getWorld().isRemote) {
                List<Vec3dCube> boxes = getTubeBoxes();
                Vec3dCube box = mop.getCube();
                int face = -1;
                if (box.equals(boxes.get(0))) {
                    face = mop.sideHit;
                } else {
                    face = getSideFromAABBIndex(boxes.indexOf(box));
                }
                color[face] = newColor;
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
            }
            return true;
        }
        if (item.getItem() instanceof ItemPart) {
            BPPart part = PartManager.getExample(item);
            if (redwireType == null && part instanceof PartRedwireFaceUninsulated) {
                if (!getWorld().isRemote) {
                    redwireType = ((IRedwire) part).getRedwireType(ForgeDirection.UNKNOWN);
                    if (!player.capabilities.isCreativeMode)
                        item.stackSize--;
                    // Redstone update
                    getRedstoneConnectionCache().recalculateConnections();
                    RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                    updateConnections();
                    getLogic().clearNodeCaches();
                    notifyUpdate();
                    sendUpdatePacket();
                }
                return true;
            }
        }
        // Removing redwire
        if (redwireType != null && item.getItem() instanceof IScrewdriver && player.isSneaking()) {
            if (!getWorld().isRemote) {
                IOHelper.spawnItemInWorld(getWorld(), PartManager.getPartInfo("wire." + redwireType.getName()).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
                redwireType = null;
                // Redstone update
                getRedstoneConnectionCache().recalculateConnections();
                RedstoneApi.getInstance().getRedstonePropagator(this, ForgeDirection.DOWN).propagate();
                ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                updateConnections();
                getLogic().clearNodeCaches();
                notifyUpdate();
                sendUpdatePacket();
            }
            return true;
        }
    }
    return false;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) ItemPart(com.bluepowermod.item.ItemPart) IScrewdriver(com.bluepowermod.api.misc.IScrewdriver) BPPart(com.bluepowermod.part.BPPart) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)

Example 3 with PartRedwireFaceUninsulated

use of com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated in project BluePower by Qmunity.

the class GateNullCell method onActivated.

// In-world customization
@Override
public boolean onActivated(EntityPlayer player, QMovingObjectPosition mop, ItemStack item) {
    Vec3d hit = new Vec3d(mop.hitVec).sub(mop.blockX, mop.blockY, mop.blockZ).rotateUndo(getFace(), Vec3d.center);
    if (item != null) {
        if (item.getItem() instanceof ItemPart) {
            IPart part = ((ItemPart) item.getItem()).createPart(item, player, null, null);
            if (part != null && part instanceof PartRedwireFaceUninsulated) {
                PartRedwireFace wire = (PartRedwireFace) part;
                if (hit.getY() > 2 / 16D) {
                    if (typeB == null) {
                        if (getWorld().isRemote)
                            return true;
                        typeB = wire.getRedwireType(ForgeDirection.UNKNOWN);
                        bundledB = false;
                        inWorldB = true;
                        getRedstoneConnectionCache().recalculateConnections();
                        sendUpdatePacket();
                        if (!player.capabilities.isCreativeMode)
                            item.stackSize--;
                        return true;
                    }
                } else {
                    if (typeA == null) {
                        if (getWorld().isRemote)
                            return true;
                        typeA = wire.getRedwireType(ForgeDirection.UNKNOWN);
                        bundledA = false;
                        inWorldA = true;
                        getRedstoneConnectionCache().recalculateConnections();
                        sendUpdatePacket();
                        if (!player.capabilities.isCreativeMode)
                            item.stackSize--;
                        return true;
                    }
                }
            }
        } else if (item.getItem() instanceof IScrewdriver && player.isSneaking()) {
            if (hit.getY() > 2 / 16D && ((hit.getY() <= 4 / 16D && hit.getX() > 0.5 - 1 / 16D && hit.getX() > 0.5 + 1 / 16D) || hit.getY() > 4 / 16D)) {
                if (typeB != null) {
                    if (getWorld().isRemote)
                        return true;
                    IOHelper.spawnItemInWorld(getWorld(), typeB.getPartInfo(MinecraftColor.NONE, bundledB).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
                    typeB = null;
                    bundledB = false;
                    inWorldB = false;
                    ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                    getRedstoneConnectionCache().recalculateConnections();
                    sendUpdatePacket();
                    return true;
                }
            } else if (hit.getY() > 2 / 16D) {
                if (typeA != null) {
                    if (getWorld().isRemote)
                        return true;
                    IOHelper.spawnItemInWorld(getWorld(), typeA.getPartInfo(MinecraftColor.NONE, bundledA).getStack(), getX() + 0.5, getY() + 0.5, getZ() + 0.5);
                    typeA = null;
                    bundledA = false;
                    inWorldA = false;
                    ((IScrewdriver) item.getItem()).damage(item, 1, player, false);
                    getRedstoneConnectionCache().recalculateConnections();
                    sendUpdatePacket();
                    return true;
                }
            }
        }
    }
    return super.onActivated(player, mop, item);
}
Also used : 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) Vec3d(uk.co.qmunity.lib.vec.Vec3d) PartRedwireFaceUninsulated(com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)

Example 4 with PartRedwireFaceUninsulated

use of com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated 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

IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)4 ItemPart (com.bluepowermod.item.ItemPart)4 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)4 PartRedwireFace (com.bluepowermod.part.wire.redstone.PartRedwireFace)3 IPart (uk.co.qmunity.lib.part.IPart)3 ItemStack (net.minecraft.item.ItemStack)2 Vec3d (uk.co.qmunity.lib.vec.Vec3d)2 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)2 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)1 RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)1 ItemScrewdriver (com.bluepowermod.item.ItemScrewdriver)1 BPPart (com.bluepowermod.part.BPPart)1 GateNullCell (com.bluepowermod.part.gate.supported.GateNullCell)1 IIcon (net.minecraft.util.IIcon)1 Vec3 (net.minecraft.util.Vec3)1 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)1 RenderHelper (uk.co.qmunity.lib.client.render.RenderHelper)1 Rotation (uk.co.qmunity.lib.transform.Rotation)1