Search in sources :

Example 36 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class PneumaticTube method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i loc, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    boolean down = shouldRenderConnection(ForgeDirection.DOWN);
    boolean up = shouldRenderConnection(ForgeDirection.UP);
    boolean north = shouldRenderConnection(ForgeDirection.NORTH);
    boolean south = shouldRenderConnection(ForgeDirection.SOUTH);
    boolean west = shouldRenderConnection(ForgeDirection.WEST);
    boolean east = shouldRenderConnection(ForgeDirection.EAST);
    boolean renderFully = shouldRenderFully();
    if (this instanceof RestrictionTube) {
        IIcon icon = IconSupplier.restrictionTubeSide;
        renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
    }
    double addedThickness = getAddedThickness();
    double wireSize = getSize() / 16D;
    double frameSeparation = 6 / 16D - addedThickness - addedThickness - 0.001;
    double frameThickness = 1 / 16D + addedThickness;
    if (pass == 0) {
        if (this instanceof RestrictionTube) {
            IIcon icon = IconSupplier.restrictionTubeSide;
            renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
        }
        if (renderFully) {
            renderer.setColor(getColorMultiplier());
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, true, true, true, true, true, true, down, up, west, east, north, south, true, getFrameIcon(), getFrameColorMultiplier());
            renderer.setColor(0xFFFFFF);
        } else {
            boolean isInWorld = getParent() != null;
            renderer.setColor(getFrameColorMultiplier());
            // Frame
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, down, up, west, east, north, south, isInWorld, getFrameIcon(), getFrameColorMultiplier());
        }
        // Tube coloring
        {
            Vec3dCube side = new Vec3dCube(0.25 + 5 / 128D, 0, 0.25 - addedThickness, 0.25 + 9 / 128D + addedThickness, 0.25, 0.25 + 2 / 128D);
            Vec3dCube side2 = new Vec3dCube(0.25 - addedThickness, 0, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25, 0.25 + 9 / 128D + addedThickness);
            Vec3dCube side3 = new Vec3dCube(0.25 - addedThickness, 0.25 - addedThickness, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25 + 4 / 128D, 0.25 + 59 / 128D);
            Vec3dCube side4 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - addedThickness, 0.25 + 5 / 128D, 0.25 + 9 / 128D + addedThickness, 0.25 + 2 / 128D, 0.25 + 56 / 128D);
            Vec3dCube side5 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - addedThickness, 0.25 - 1 / 128D, 0.25 + 9 / 128D + addedThickness, 0.25 + 2 / 128D, 0.25 + 65 / 128D);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                TubeColor c = color[d.ordinal()];
                if (c != TubeColor.NONE) {
                    try {
                        renderer.setColor(MinecraftColor.values()[15 - c.ordinal()].getHex());
                        if (connections[d.ordinal()]) {
                            for (int i = 0; i < 4; i++) {
                                renderer.renderBox(side.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                renderer.renderBox(side2.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                if (renderFully)
                                    renderer.renderBox(side3.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                            }
                        } else if (renderFully) {
                            for (int i = 0; i < 4; i++) renderer.renderBox(side4.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        } else {
                            for (int i = 1; i < 4; i += 2) renderer.renderBox(side5.clone().rotate(0, (i + ((shouldRenderConnection(ForgeDirection.NORTH) || (shouldRenderConnection(ForgeDirection.UP) && (d == ForgeDirection.NORTH || d == ForgeDirection.SOUTH))) ? 1 : 0)) * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        }
                        renderer.setColor(0xFFFFFF);
                    } catch (Exception ex) {
                        System.out.println("Err on side " + d + ". Color: " + c);
                    }
                }
            }
        }
        if (redwireType != null) {
            frameThickness /= 1.5;
            frameSeparation -= 1 / 32D;
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, renderFully || shouldRenderConnection(ForgeDirection.DOWN), renderFully || shouldRenderConnection(ForgeDirection.UP), renderFully || shouldRenderConnection(ForgeDirection.WEST), renderFully || shouldRenderConnection(ForgeDirection.EAST), renderFully || shouldRenderConnection(ForgeDirection.NORTH), renderFully || shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null, IconSupplier.wire, WireHelper.getColorForPowerLevel(redwireType, getPower()));
            Vec3dCube c = new Vec3dCube(0.5 - 1 / 56D, 0, 0.2, 0.5 + 1 / 56D, 1 / 32D, 0.8);
            renderer.setColor(WireHelper.getColorForPowerLevel(redwireType, getPower()));
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (redstoneConnections[d.ordinal()] && !connections[d.ordinal()]) {
                    renderer.addTransformation(new Rotation(d));
                    for (int i = 0; i < 2; i++) {
                        renderer.addTransformation(new Rotation(0, 45 + 90 * i, 0));
                        renderer.renderBox(c.clone(), IconSupplier.wire);
                        renderer.removeTransformation();
                    }
                    renderer.removeTransformation();
                }
            }
            renderer.setColor(0xFFFFFF);
        }
    } else {
        IIcon glass = this instanceof MagTube ? IconSupplier.magTubeGlass : IconSupplier.pneumaticTubeGlass;
        IIcon glass2 = this instanceof MagTube ? IconSupplier.magTubeGlass2 : IconSupplier.pneumaticTubeGlass2;
        if (!(this instanceof RestrictionTube)) {
            renderer.setRenderSides(!down, !up, !west, !east, !north, !south);
            if (renderFully) {
                renderer.renderBox(new Vec3dCube(4.5 / 16D, 4.5 / 16D, 4.5 / 16D, 11.5 / 16D, 11.5 / 16D, 11.5 / 16D), glass);
            } else {
                boolean ud = west || east;
                boolean we = north || south;
                boolean ns = west || east;
                renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
                renderer.renderBox(new Vec3dCube(4.5 / 16D, 4.5 / 16D, 4.5 / 16D, 11.5 / 16D, 11.5 / 16D, 11.5 / 16D), glass2);
            }
            renderer.resetRenderedSides();
            renderer.resetTextureRotations();
        }
        Vec3dCube c = new Vec3dCube(4.5 / 16D, 0, 4.5 / 16D, 11.5 / 16D, 4.5 / 16D, 11.5 / 16D);
        if (renderFully) {
            boolean ud = west || east;
            boolean we = north || south;
            boolean ns = west || east;
            renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (shouldRenderConnection(d)) {
                    renderer.setRenderSide(d, false);
                    renderer.setRenderSide(d.getOpposite(), false);
                    renderer.renderBox(c.clone().rotate(d, Vec3d.center), glass);
                    renderer.resetRenderedSides();
                }
            }
        } else {
            boolean ud = west || east;
            boolean we = north || south;
            boolean ns = west || east;
            renderer.setTextureRotations(ud ? 1 : 0, ud ? 1 : 0, we ? 1 : 0, we ? 1 : 0, ns ? 1 : 0, ns ? 1 : 0);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                if (shouldRenderConnection(d)) {
                    renderer.setRenderSide(d, false);
                    renderer.setRenderSide(d.getOpposite(), false);
                    renderer.renderBox(c.clone().rotate(d, Vec3d.center), glass2);
                    renderer.resetRenderedSides();
                }
            }
        }
    }
    return true;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) IIcon(net.minecraft.util.IIcon) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Rotation(uk.co.qmunity.lib.transform.Rotation) IOException(java.io.IOException) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 37 with Vec3dCube

use of uk.co.qmunity.lib.vec.Vec3dCube in project BluePower by Qmunity.

the class PneumaticTubeOpaque method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i loc, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    if (pass == 0) {
        boolean renderFully = false;
        int count = 0;
        for (int i = 0; i < 6; i++) {
            if (connections[i] || redstoneConnections[i])
                count++;
            if (i % 2 == 0 && connections[i] != connections[i + 1])
                renderFully = true;
        }
        renderFully |= count > 2 || count == 0;
        IIcon icon = this instanceof RestrictionTubeOpaque ? (renderFully ? IconSupplier.restrictionTubeNodeOpaque : IconSupplier.restrictionTubeSideOpaque) : renderFully ? IconSupplier.pneumaticTubeOpaqueNode : IconSupplier.pneumaticTubeOpaqueSide;
        if (shouldRenderConnection(ForgeDirection.EAST) || shouldRenderConnection(ForgeDirection.WEST))
            renderer.setTextureRotations(1, 1, 0, 0, 1, 1);
        if (shouldRenderConnection(ForgeDirection.NORTH) || shouldRenderConnection(ForgeDirection.SOUTH))
            renderer.setTextureRotations(0, 0, 1, 1, 0, 0);
        renderer.renderBox(new Vec3dCube(0.25, 0.25, 0.25, 0.75, 0.75, 0.75), icon);
        renderer.resetTextureRotations();
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            if (shouldRenderConnection(d)) {
                renderer.addTransformation(new Rotation(d));
                renderer.renderBox(new Vec3dCube(0.25, 0, 0.25, 0.75, 0.25, 0.75), IconSupplier.pneumaticTubeOpaqueNode, null, icon, icon, icon, icon);
                renderer.removeTransformation();
            }
        }
        if (getRedwireType() != null) {
            double wireSize = getSize() / 16D;
            double frameSeparation = 6 / 16D - (wireSize - 2 / 16D);
            double frameThickness = 1 / 16D;
            frameThickness /= 1.5;
            frameSeparation -= 1 / 32D;
            renderFrame(renderer, wireSize, frameSeparation, frameThickness, renderFully || shouldRenderConnection(ForgeDirection.DOWN), renderFully || shouldRenderConnection(ForgeDirection.UP), renderFully || shouldRenderConnection(ForgeDirection.WEST), renderFully || shouldRenderConnection(ForgeDirection.EAST), renderFully || shouldRenderConnection(ForgeDirection.NORTH), renderFully || shouldRenderConnection(ForgeDirection.SOUTH), redstoneConnections[ForgeDirection.DOWN.ordinal()], redstoneConnections[ForgeDirection.UP.ordinal()], redstoneConnections[ForgeDirection.WEST.ordinal()], redstoneConnections[ForgeDirection.EAST.ordinal()], redstoneConnections[ForgeDirection.NORTH.ordinal()], redstoneConnections[ForgeDirection.SOUTH.ordinal()], getParent() != null && getWorld() != null, IconSupplier.wire, WireHelper.getColorForPowerLevel(getRedwireType(), getPower()));
        }
        // Tube coloring
        {
            Vec3dCube side = new Vec3dCube(0.25 + 5 / 128D, 0, 0.25 - 1 / 128D, 0.25 + 9 / 128D, 0.25, 0.25 + 2 / 128D);
            Vec3dCube side2 = new Vec3dCube(0.25 - 1 / 128D, 0, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25, 0.25 + 9 / 128D);
            Vec3dCube side3 = new Vec3dCube(0.25 - 1 / 128D, 0.25 - 1 / 128D, 0.25 + 5 / 128D, 0.25 + 2 / 128D, 0.25 + 2 / 128D, 0.25 + 59 / 128D);
            Vec3dCube side4 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - 1 / 128D, 0.25 + 5 / 128D, 0.25 + 9 / 128D, 0.25 + 2 / 128D, 0.25 + 56 / 128D);
            Vec3dCube side5 = new Vec3dCube(0.25 + 5 / 128D, 0.25 - 1 / 128D, 0.25 - 1 / 128D, 0.25 + 9 / 128D, 0.25 + 2 / 128D, 0.25 + 65 / 128D);
            for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
                TubeColor c = color[d.ordinal()];
                if (c != TubeColor.NONE) {
                    try {
                        renderer.setColor(MinecraftColor.values()[15 - c.ordinal()].getHex());
                        if (connections[d.ordinal()]) {
                            for (int i = 0; i < 4; i++) {
                                renderer.renderBox(side.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                renderer.renderBox(side2.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                                if (renderFully)
                                    renderer.renderBox(side3.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                            }
                        } else if (renderFully) {
                            for (int i = 0; i < 4; i++) renderer.renderBox(side4.clone().rotate(0, i * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        } else {
                            for (int i = 1; i < 4; i += 2) renderer.renderBox(side5.clone().rotate(0, (i + ((shouldRenderConnection(ForgeDirection.NORTH) || (shouldRenderConnection(ForgeDirection.UP) && (d == ForgeDirection.NORTH || d == ForgeDirection.SOUTH))) ? 1 : 0)) * 90, 0, Vec3d.center).rotate(d, Vec3d.center), IconSupplier.pneumaticTubeColoring);
                        }
                        renderer.setColor(0xFFFFFF);
                    } catch (Exception ex) {
                        System.out.println("Err on side " + d + ". Color: " + c);
                    }
                }
            }
        }
    }
    return true;
}
Also used : TubeColor(com.bluepowermod.api.tube.IPneumaticTube.TubeColor) IIcon(net.minecraft.util.IIcon) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)37 SideOnly (cpw.mods.fml.relauncher.SideOnly)13 IIcon (net.minecraft.util.IIcon)11 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)8 ArrayList (java.util.ArrayList)7 Rotation (uk.co.qmunity.lib.transform.Rotation)6 Translation (uk.co.qmunity.lib.transform.Translation)5 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)3 RenderHelper (uk.co.qmunity.lib.client.render.RenderHelper)3 IScrewdriver (com.bluepowermod.api.misc.IScrewdriver)2 BlockLamp (com.bluepowermod.block.machine.BlockLamp)2 ItemPart (com.bluepowermod.item.ItemPart)2 PartRedwireFaceUninsulated (com.bluepowermod.part.wire.redstone.PartRedwireFace.PartRedwireFaceUninsulated)2 ItemStack (net.minecraft.item.ItemStack)2 Vec3d (uk.co.qmunity.lib.vec.Vec3d)2 Vec3i (uk.co.qmunity.lib.vec.Vec3i)2 IGateComponent (com.bluepowermod.api.gate.IGateComponent)1 IIntegratedCircuitPart (com.bluepowermod.api.gate.IIntegratedCircuitPart)1 BPPart (com.bluepowermod.part.BPPart)1 GateComponentQuartzResonator (com.bluepowermod.part.gate.component.GateComponentQuartzResonator)1