Search in sources :

Example 51 with IIcon

use of net.minecraft.util.IIcon in project BluePower by Qmunity.

the class Accelerator method renderDynamic.

@Override
@SideOnly(Side.CLIENT)
public void renderDynamic(Vec3d loc, double delta, int pass) {
    super.renderDynamic(loc, delta, pass);
    if (pass == 0) {
        Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
        Tessellator t = Tessellator.instance;
        GL11.glPushMatrix();
        GL11.glTranslatef((float) loc.getX() + 0.5F, (float) loc.getY() + 0.5F, (float) loc.getZ() + 0.5F);
        if (rotation == ForgeDirection.NORTH || rotation == ForgeDirection.SOUTH) {
            GL11.glRotated(90, 1, 0, 0);
        } else if (rotation == ForgeDirection.EAST || rotation == ForgeDirection.WEST) {
            GL11.glRotated(90, 0, 0, 1);
        }
        GL11.glTranslatef((float) -loc.getX() - 0.5F, (float) -loc.getY() - 0.5F, (float) -loc.getZ() - 0.5F);
        t.startDrawingQuads();
        t.setColorOpaque_F(1, 1, 1);
        t.addTranslation((float) loc.getX(), (float) loc.getY(), (float) loc.getZ());
        IIcon icon = isPowered() ? IconSupplier.acceleratorFrontPowered : IconSupplier.acceleratorFront;
        double minX = icon.getInterpolatedU(0);
        double maxX = icon.getInterpolatedU(16);
        double minY = icon.getInterpolatedV(0);
        double maxY = icon.getInterpolatedV(16);
        t.setNormal(0, -1, 0);
        // minY
        t.addVertexWithUV(0, 4 / 16D, 0, maxX, maxY);
        t.addVertexWithUV(1, 4 / 16D, 0, minX, maxY);
        t.addVertexWithUV(1, 4 / 16D, 1, minX, minY);
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, minY);
        t.setNormal(0, 1, 1);
        // maxY
        t.addVertexWithUV(0, 12 / 16D, 0, maxX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, minY);
        t.addVertexWithUV(1, 12 / 16D, 0, maxX, minY);
        icon = isPowered() ? IconSupplier.acceleratorSidePowered : IconSupplier.acceleratorSide;
        minX = icon.getInterpolatedU(4);
        maxX = icon.getInterpolatedU(12);
        minY = icon.getInterpolatedV(0);
        maxY = icon.getInterpolatedV(16);
        t.setNormal(0, 0, 1);
        // maxZ
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, minY);
        t.addVertexWithUV(1, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 1, minX, minY);
        t.setNormal(0, 0, -1);
        // minZ
        t.addVertexWithUV(0, 4 / 16D, 0, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 0, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 0, maxX, minY);
        t.addVertexWithUV(1, 4 / 16D, 0, minX, minY);
        t.setNormal(-1, 0, 0);
        // minX
        t.addVertexWithUV(0, 4 / 16D, 0, maxX, minY);
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 0, minX, minY);
        t.setNormal(1, 0, 0);
        // maxX
        t.addVertexWithUV(1, 4 / 16D, 0, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 0, minX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, minY);
        t.addVertexWithUV(1, 4 / 16D, 1, maxX, minY);
        icon = IconSupplier.acceleratorInside;
        minX = icon.getInterpolatedU(4);
        maxX = icon.getInterpolatedU(12);
        minY = icon.getInterpolatedV(4);
        maxY = icon.getInterpolatedV(12);
        // inside maxZ
        t.addVertexWithUV(0, 4 / 16D, 6 / 16D, minX, minY);
        t.addVertexWithUV(1, 4 / 16D, 6 / 16D, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 6 / 16D, maxX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 6 / 16D, minX, minY);
        // inside minZ
        t.addVertexWithUV(0, 4 / 16D, 10 / 16D, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 10 / 16D, minX, minY);
        t.addVertexWithUV(1, 12 / 16D, 10 / 16D, maxX, minY);
        t.addVertexWithUV(1, 4 / 16D, 10 / 16D, maxX, maxY);
        // inside minX
        t.addVertexWithUV(10 / 16D, 4 / 16D, 0, minX, minY);
        t.addVertexWithUV(10 / 16D, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(10 / 16D, 12 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(10 / 16D, 12 / 16D, 0, minX, minY);
        // inside maxX
        t.addVertexWithUV(6 / 16D, 4 / 16D, 0, minX, minY);
        t.addVertexWithUV(6 / 16D, 12 / 16D, 0, minX, maxY);
        t.addVertexWithUV(6 / 16D, 12 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(6 / 16D, 4 / 16D, 1, maxX, minY);
        t.addTranslation((float) -loc.getX(), (float) -loc.getY(), (float) -loc.getZ());
        t.draw();
        GL11.glPopMatrix();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 52 with IIcon

use of net.minecraft.util.IIcon in project BluePower by Qmunity.

the class MagTube method renderSide.

/**
     * Render method that works, and now should be buried under the ground so no-one looks at it
     */
@Override
@SideOnly(Side.CLIENT)
protected void renderSide() {
    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    Tessellator t = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    if (getParent() == null || getWorld() == null) {
    } else {
        if (connections[2]) {
            GL11.glRotated(90, 1, 0, 0);
        } else if (connections[4]) {
            GL11.glRotated(90, 0, 0, 1);
        }
    }
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
    t.startDrawingQuads();
    double min = 2 / 16D;
    double max = 14 / 16D;
    double inMin = 12.001 / 16D;
    double inMax = 3.999 / 16D;
    IIcon icon = IconSupplier.magCoilSide;
    double minX = icon.getInterpolatedU(min * 16);
    double maxX = icon.getInterpolatedU(max * 16);
    double minY = icon.getInterpolatedV(min * 16);
    double maxY = icon.getInterpolatedV(max * 16);
    t.setNormal(0, 0, 1);
    // maxZ
    t.addVertexWithUV(min, min, max, maxX, maxY);
    t.addVertexWithUV(max, min, max, minX, maxY);
    t.addVertexWithUV(max, max, max, minX, minY);
    t.addVertexWithUV(min, max, max, maxX, minY);
    // inside maxZ
    t.addVertexWithUV(min, min, inMax, maxX, maxY);
    t.addVertexWithUV(max, min, inMax, minX, maxY);
    t.addVertexWithUV(max, max, inMax, minX, minY);
    t.addVertexWithUV(min, max, inMax, maxX, minY);
    t.setNormal(0, 0, -1);
    // minZ
    t.addVertexWithUV(min, min, min, minX, maxY);
    t.addVertexWithUV(min, max, min, minX, minY);
    t.addVertexWithUV(max, max, min, maxX, minY);
    t.addVertexWithUV(max, min, min, maxX, maxY);
    // inside minZ
    t.addVertexWithUV(min, min, inMin, maxX, maxY);
    t.addVertexWithUV(min, max, inMin, minX, minY);
    t.addVertexWithUV(max, max, inMin, minX, minY);
    t.addVertexWithUV(max, min, inMin, maxX, maxY);
    t.setNormal(-1, 0, 0);
    // minX
    t.addVertexWithUV(min, min, min, maxX, maxY);
    t.addVertexWithUV(min, min, max, minX, maxY);
    t.addVertexWithUV(min, max, max, minX, minY);
    t.addVertexWithUV(min, max, min, maxX, minY);
    // inside minX
    t.addVertexWithUV(inMin, min, min, maxX, maxY);
    t.addVertexWithUV(inMin, min, max, minX, maxY);
    t.addVertexWithUV(inMin, max, max, minX, minY);
    t.addVertexWithUV(inMin, max, min, maxX, minY);
    t.setNormal(1, 0, 0);
    // maxX
    t.addVertexWithUV(max, min, min, minX, minY);
    t.addVertexWithUV(max, max, min, minX, maxY);
    t.addVertexWithUV(max, max, max, maxX, maxY);
    t.addVertexWithUV(max, min, max, maxX, minY);
    // maxX
    t.addVertexWithUV(inMax, min, min, maxX, minY);
    t.addVertexWithUV(inMax, max, min, minX, maxY);
    t.addVertexWithUV(inMax, max, max, minX, maxY);
    t.addVertexWithUV(inMax, min, max, maxX, minY);
    icon = IconSupplier.magCoilFront;
    minX = icon.getInterpolatedU(min * 16);
    maxX = icon.getInterpolatedU(max * 16);
    minY = icon.getInterpolatedV(min * 16);
    maxY = icon.getInterpolatedV(max * 16);
    for (int i = 2; i < 16; i += 8) {
        t.setNormal(0, 1, 0);
        // maxY
        t.addVertexWithUV(min, 1 - i / 16D, min, maxX, maxY);
        t.addVertexWithUV(min, 1 - i / 16D, max, minX, maxY);
        t.addVertexWithUV(max, 1 - i / 16D, max, minX, minY);
        t.addVertexWithUV(max, 1 - i / 16D, min, maxX, minY);
        t.setNormal(0, -1, 0);
        // minY
        t.addVertexWithUV(min, i / 16D, min, maxX, maxY);
        t.addVertexWithUV(max, i / 16D, min, minX, maxY);
        t.addVertexWithUV(max, i / 16D, max, minX, minY);
        t.addVertexWithUV(min, i / 16D, max, maxX, minY);
    }
    t.draw();
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) IIcon(net.minecraft.util.IIcon) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 53 with IIcon

use of net.minecraft.util.IIcon in project BluePower by Qmunity.

the class GateTransceiver method renderStatic.

@Override
@SideOnly(Side.CLIENT)
public boolean renderStatic(Vec3i translation, RenderHelper renderer, RenderBlocks renderBlocks, int pass) {
    super.renderStatic(translation, renderer, renderBlocks, pass);
    if (getParent() != null)
        renderer.addTransformation(new Rotation(0, 180, 0));
    IIcon obsidian = Blocks.obsidian.getIcon(0, 0);
    IIcon quartz = Blocks.quartz_block.getIcon(0, 0);
    IIcon iron = Blocks.iron_block.getIcon(0, 0);
    IIcon gold = Blocks.gold_block.getIcon(0, 0);
    // Base
    renderer.renderBox(new Vec3dCube(7 / 16D, 2 / 16D, 7 / 16D, 9 / 16D, 8 / 16D, 9 / 16D), obsidian);
    if (getParent() == null || getWorld() == null)
        renderer.addTransformation(new Rotation(0, -(System.currentTimeMillis() / 100D) % 360, 0));
    renderer.addTransformation(new Rotation(45, 0, 0));
    // Post
    renderer.renderBox(new Vec3dCube(15 / 32D, 9 / 16D, 15 / 32D, 17 / 32D, 10 / 16D, 17 / 32D), iron);
    // Ball thingy
    renderer.renderBox(new Vec3dCube(7 / 16D, 10 / 16D, 7 / 16D, 9 / 16D, 12 / 16D, 9 / 16D), gold);
    renderer.renderBox(new Vec3dCube(6 / 16D, 8 / 16D, 5 / 16D, 10 / 16D, 9 / 16D, 11 / 16D), quartz);
    renderer.renderBox(new Vec3dCube(5 / 16D, 8 / 16D, 6 / 16D, 11 / 16D, 9 / 16D, 10 / 16D), quartz);
    for (int i = 0; i < 4; i++) {
        renderer.renderBox(new Vec3dCube(5 / 16D, 9 / 16D, 10 / 16D, 6 / 16D, 10 / 16D, 11 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 9 / 16D, 6 / 16D, 5 / 16D, 10 / 16D, 10 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 10 / 16D, 5 / 16D, 5 / 16D, 11 / 16D, 11 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(4 / 16D, 11 / 16D, 11 / 16D, 5 / 16D, 12 / 16D, 12 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
        renderer.renderBox(new Vec3dCube(3 / 16D, 11 / 16D, 4 / 16D, 4 / 16D, 12 / 16D, 12 / 16D).rotate(0, i * 90, 0, Vec3d.center), quartz);
    }
    renderer.resetTransformations();
    return true;
}
Also used : IIcon(net.minecraft.util.IIcon) Rotation(uk.co.qmunity.lib.transform.Rotation) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 54 with IIcon

use of net.minecraft.util.IIcon 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 55 with IIcon

use of net.minecraft.util.IIcon 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

IIcon (net.minecraft.util.IIcon)79 Tessellator (net.minecraft.client.renderer.Tessellator)19 SideOnly (cpw.mods.fml.relauncher.SideOnly)17 Vec3dCube (uk.co.qmunity.lib.vec.Vec3dCube)11 ItemStack (net.minecraft.item.ItemStack)6 EntityItem (net.minecraft.entity.item.EntityItem)5 Fluid (net.minecraftforge.fluids.Fluid)5 Rotation (uk.co.qmunity.lib.transform.Rotation)5 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 AMVector2 (am2.api.math.AMVector2)3 Block (net.minecraft.block.Block)3 EntityDiggingFX (net.minecraft.client.particle.EntityDiggingFX)3 TubeColor (com.bluepowermod.api.tube.IPneumaticTube.TubeColor)2 IExplosiveHandler (com.builtbroken.mc.api.explosive.IExplosiveHandler)2 ITexturedExplosiveHandler (com.builtbroken.mc.api.explosive.ITexturedExplosiveHandler)2 IExplosiveContainerItem (com.builtbroken.mc.api.items.explosives.IExplosiveContainerItem)2 ItemStackWrapper (com.builtbroken.mc.prefab.items.ItemStackWrapper)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 FluidStack (net.minecraftforge.fluids.FluidStack)2 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)2