Search in sources :

Example 1 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project MinecraftForge by MinecraftForge.

the class LightUtil method getTessellator.

public static IVertexConsumer getTessellator() {
    if (tessellator == null) {
        Tessellator tes = Tessellator.getInstance();
        VertexBuffer wr = tes.getBuffer();
        tessellator = new VertexBufferConsumer(wr);
    }
    return tessellator;
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Example 2 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project BluePower by Qmunity.

the class RenderHelper method drawTesselatedTexturedCube.

/**
     * Draws a cube with the size of vector. It uses the texture that is already bound and maps that completely This uses the Tessellator
     *
     * @author Koen Beckers (K4Unl)
     * @param vector
     */
public static void drawTesselatedTexturedCube(Vec3dCube vector) {
    Tessellator t = Tessellator.instance;
    boolean wasTesselating = false;
    // Check if we were already tesselating
    try {
        t.startDrawingQuads();
    } catch (IllegalStateException e) {
        wasTesselating = true;
    }
    double minU = 0;
    double maxU = 1;
    double minV = 0;
    double maxV = 1;
    // Top side
    t.setNormal(0, 1, 0);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, maxV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, maxV);
    // Bottom side
    t.setNormal(0, -1, 0);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
    // Draw west side:
    t.setNormal(-1, 0, 0);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), minU, minV);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
    // Draw east side:
    t.setNormal(1, 0, 0);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), maxU, maxV);
    // Draw north side
    t.setNormal(0, 0, -1);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMinZ(), minU, maxV);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMinZ(), minU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMinZ(), maxU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMinZ(), maxU, maxV);
    // Draw south side
    t.setNormal(0, 0, 1);
    t.addVertexWithUV(vector.getMinX(), vector.getMinY(), vector.getMaxZ(), minU, maxV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMinY(), vector.getMaxZ(), minU, minV);
    t.addVertexWithUV(vector.getMaxX(), vector.getMaxY(), vector.getMaxZ(), maxU, minV);
    t.addVertexWithUV(vector.getMinX(), vector.getMaxY(), vector.getMaxZ(), maxU, maxV);
    if (!wasTesselating) {
        t.draw();
    }
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 3 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project BluePower by Qmunity.

the class RenderLamp method renderItem.

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    GL11.glPushMatrix();
    {
        switch(type) {
            case ENTITY:
                GL11.glTranslated(-0.5, -0.5, -0.5);
                break;
            case EQUIPPED:
                break;
            case EQUIPPED_FIRST_PERSON:
                GL11.glTranslated(0, -0.1, 0);
                break;
            case INVENTORY:
                GL11.glTranslated(0, -0.1, 0);
                break;
            default:
                break;
        }
        BlockLamp block = (BlockLamp) Block.getBlockFromItem(item.getItem());
        int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
        int r = (block.getColor() & redMask) >> 16;
        int g = (block.getColor() & greenMask) >> 8;
        int b = (block.getColor() & blueMask);
        Vec3dCube cube = new Vec3dCube(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
        Tessellator t = Tessellator.instance;
        t.startDrawingQuads();
        t.setColorOpaque(r, g, b);
        RenderHelper h = RenderHelper.instance;
        h.reset();
        h.setColor(block.getColor());
        h.renderBox(cube, block.isInverted() ? BlockLamp.on : BlockLamp.off);
        h.reset();
        t.draw();
        if (block.isInverted()) {
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
            // GL11.glAlphaFunc(GL11.GL_EQUAL, (power / 15F) * 1F);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_LIGHTING);
            // GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDepthMask(false);
            GL11.glBegin(GL11.GL_QUADS);
            com.bluepowermod.client.render.RenderHelper.drawColoredCube(cube.clone().expand(0.8 / 16D), r / 256D, g / 256D, b / 256D, 0.625D);
            GL11.glEnd();
            GL11.glDepthMask(true);
            GL11.glEnable(GL11.GL_CULL_FACE);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            // GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
            GL11.glDisable(GL11.GL_BLEND);
        }
    }
    GL11.glPopMatrix();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator) RenderHelper(uk.co.qmunity.lib.client.render.RenderHelper) BlockLamp(com.bluepowermod.block.machine.BlockLamp) Vec3dCube(uk.co.qmunity.lib.vec.Vec3dCube)

Example 4 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class CustomBlockRenderer method renderBlock.

public void renderBlock(RenderInfo info, IBlockAccess blockAccess, double x, double y, double z, int lightX, int lightY, int lightZ, boolean doLight, boolean doTessellating) {
    float lightBottom = 0.5F;
    float lightTop = 1.0F;
    float lightEastWest = 0.8F;
    float lightNorthSouth = 0.6F;
    Tessellator tessellator = Tessellator.instance;
    boolean realDoLight = doLight;
    if (blockAccess == null) {
        realDoLight = false;
    }
    // TODO: needs to cancel the test because the variable is now private... May need to
    // duplicate the tessellator code.
    //if (doTessellating && !tessellator.isDrawing)
    tessellator.startDrawingQuads();
    float light = 0;
    if (realDoLight) {
        if (info.light < 0) {
            light = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ);
            light = light + ((1.0f - light) * 0.4f);
        } else {
            light = info.light;
        }
        int brightness = 0;
        if (info.brightness < 0) {
            brightness = info.baseBlock.getMixedBrightnessForBlock(blockAccess, lightX, lightY, lightZ);
        } else {
            brightness = info.brightness;
        }
        tessellator.setBrightness(brightness);
        tessellator.setColorOpaque_F(lightBottom * light, lightBottom * light, lightBottom * light);
    } else {
        //			tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
        if (info.brightness >= 0) {
            tessellator.setBrightness(info.brightness);
        }
    }
    renderBlocks.setRenderBounds(info.minX, info.minY, info.minZ, info.maxX, info.maxY, info.maxZ);
    if (info.renderSide[0]) {
        renderBlocks.renderFaceYNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(0));
    }
    if (realDoLight) {
        tessellator.setColorOpaque_F(lightTop * light, lightTop * light, lightTop * light);
    }
    if (info.renderSide[1]) {
        renderBlocks.renderFaceYPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(1));
    }
    if (realDoLight) {
        tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
    }
    if (info.renderSide[2]) {
        renderBlocks.renderFaceZNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(2));
    }
    if (realDoLight) {
        tessellator.setColorOpaque_F(lightEastWest * light, lightEastWest * light, lightEastWest * light);
    }
    if (info.renderSide[3]) {
        renderBlocks.renderFaceZPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(3));
    }
    if (realDoLight) {
        tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
    }
    if (info.renderSide[4]) {
        renderBlocks.renderFaceXNeg(info.baseBlock, x, y, z, info.getBlockTextureFromSide(4));
    }
    if (realDoLight) {
        tessellator.setColorOpaque_F(lightNorthSouth * light, lightNorthSouth * light, lightNorthSouth * light);
    }
    if (info.renderSide[5]) {
        renderBlocks.renderFaceXPos(info.baseBlock, x, y, z, info.getBlockTextureFromSide(5));
    }
    // TODO: needs to cancel the test because the variable is now private... May need to
    // duplicate the tessellator code.
    //if (doTessellating && tessellator.isDrawing)
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Example 5 with Tessellator

use of net.minecraft.client.renderer.Tessellator in project LogisticsPipes by RS485.

the class FluidContainerRenderer method renderIcon.

public void renderIcon(int x, int y, IIcon par3Icon, int width, int height, double zLevel) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.addVertexWithUV(x + 0, y + height, zLevel, par3Icon.getInterpolatedU(x), par3Icon.getInterpolatedV(y + height));
    tessellator.addVertexWithUV(x + width, y + height, zLevel, par3Icon.getInterpolatedU(x + width), par3Icon.getInterpolatedV(y + height));
    tessellator.addVertexWithUV(x + width, y + 0, zLevel, par3Icon.getInterpolatedU(x + width), par3Icon.getInterpolatedV(y));
    tessellator.addVertexWithUV(x + 0, y + 0, zLevel, par3Icon.getInterpolatedU(x), par3Icon.getInterpolatedV(y));
    tessellator.draw();
}
Also used : Tessellator(net.minecraft.client.renderer.Tessellator)

Aggregations

Tessellator (net.minecraft.client.renderer.Tessellator)618 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)290 WorldRenderer (net.minecraft.client.renderer.WorldRenderer)54 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)42 BlockPos (net.minecraft.util.math.BlockPos)37 ResourceLocation (net.minecraft.util.ResourceLocation)31 Vec3d (net.minecraft.util.math.Vec3d)30 EnumFacing (net.minecraft.util.EnumFacing)24 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)23 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)19 IIcon (net.minecraft.util.IIcon)19 Random (java.util.Random)18 IBlockState (net.minecraft.block.state.IBlockState)17 Minecraft (net.minecraft.client.Minecraft)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 World (net.minecraft.world.World)14 Block (net.minecraft.block.Block)13 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)13 ArrayList (java.util.ArrayList)12 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)12