buildcraftAdditions.client.render.RendererKEBT2.java Source code

Java tutorial

Introduction

Here is the source code for buildcraftAdditions.client.render.RendererKEBT2.java

Source

package buildcraftAdditions.client.render;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import buildcraftAdditions.tileEntities.TileKEBT2;

/**
 * Copyright (c) 2014, AEnterprise
 * http://buildcraftadditions.wordpress.com/
 * Buildcraft Additions is distributed under the terms of GNU GPL v3.0
 * Please check the contents of the license located in
 * http://buildcraftadditions.wordpress.com/wiki/licensing-stuff/
 */
public class RendererKEBT2 extends TileEntitySpecialRenderer {
    public ResourceLocation side[] = new ResourceLocation[] {
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides0.png"),
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides1.png"),
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides2.png"),
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides3.png"),
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides4.png"),
            new ResourceLocation("bcadditions", "textures/blocks/energyBufferMultiblockSides5.png") };
    public ResourceLocation topAndBottom = new ResourceLocation("bcadditions",
            "textures/blocks/energyBufferMultiblockTopAndBottom.png");
    public ResourceLocation singleBlock = new ResourceLocation("bcadditions",
            "textures/blocks/energyBufferMultiblockRaw.png");

    @Override
    public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float fl) {
        TileKEBT2 keb = (TileKEBT2) entity;
        if (!keb.isMaster)
            return;
        bindTexture(side[keb.energyState]);
        RenderHelper.disableStandardItemLighting();
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        Tessellator tessellator = Tessellator.instance;
        tessellator.startDrawingQuads();

        //NORTH
        tessellator.addVertexWithUV(0, 0, -1, 1, 1);
        tessellator.addVertexWithUV(0, 2, -1, 1, 0);
        tessellator.addVertexWithUV(2, 2, -1, 0, 0);
        tessellator.addVertexWithUV(2, 0, -1, 0, 1);

        //EAST
        tessellator.addVertexWithUV(2, 0, -1, 0, 1);
        tessellator.addVertexWithUV(2, 2, -1, 0, 0);
        tessellator.addVertexWithUV(2, 2, 1, 1, 0);
        tessellator.addVertexWithUV(2, 0, 1, 1, 1);

        //SOUTH
        tessellator.addVertexWithUV(2, 0, 1, 0, 1);
        tessellator.addVertexWithUV(2, 2, 1, 0, 0);
        tessellator.addVertexWithUV(0, 2, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 1, 1, 1);

        //WEST
        tessellator.addVertexWithUV(0, 0, 1, 1, 1);
        tessellator.addVertexWithUV(0, 2, 1, 1, 0);
        tessellator.addVertexWithUV(0, 2, -1, 0, 0);
        tessellator.addVertexWithUV(0, 0, -1, 0, 1);
        tessellator.draw();

        bindTexture(topAndBottom);
        tessellator.startDrawingQuads();

        //BOTTOM
        tessellator.addVertexWithUV(2, 0, -1, 1, 1);
        tessellator.addVertexWithUV(2, 0, 1, 1, 0);
        tessellator.addVertexWithUV(0, 0, 1, 0, 0);
        tessellator.addVertexWithUV(0, 0, -1, 0, 1);

        //TOP
        tessellator.addVertexWithUV(0, 2, -1, 0, 1);
        tessellator.addVertexWithUV(0, 2, 1, 0, 0);
        tessellator.addVertexWithUV(2, 2, 1, 1, 0);
        tessellator.addVertexWithUV(2, 2, -1, 1, 1);

        tessellator.draw();
        GL11.glPopMatrix();
        RenderHelper.enableStandardItemLighting();
    }
}