Java Code Examples for net.minecraft.client.renderer.Tessellator#setColorOpaque_F()

The following examples show how to use net.minecraft.client.renderer.Tessellator#setColorOpaque_F() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MoCEntityFXUndead.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
	//func_98187_b = bindTexture(String)
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(MoCreatures.proxy.MISC_TEXTURE + getCurrentTexture());
    float sizeFactor = 0.1F * this.particleScale;
    float var13 = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
    float var14 = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
    float var15 = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
    float var16 = 1F;
    par1Tessellator.setColorOpaque_F(this.particleRed * var16, this.particleGreen * var16, this.particleBlue * var16);
    par1Tessellator.addVertexWithUV((double) (var13 - par3 * sizeFactor - par6 * sizeFactor), (double) (var14 - par4 * sizeFactor), (double) (var15 - par5 * sizeFactor - par7 * sizeFactor), 0D, 1D);
    par1Tessellator.addVertexWithUV((double) (var13 - par3 * sizeFactor + par6 * sizeFactor), (double) (var14 + par4 * sizeFactor), (double) (var15 - par5 * sizeFactor + par7 * sizeFactor), 1D, 1D);
    par1Tessellator.addVertexWithUV((double) (var13 + par3 * sizeFactor + par6 * sizeFactor), (double) (var14 + par4 * sizeFactor), (double) (var15 + par5 * sizeFactor + par7 * sizeFactor), 1D, 0D);
    par1Tessellator.addVertexWithUV((double) (var13 + par3 * sizeFactor - par6 * sizeFactor), (double) (var14 - par4 * sizeFactor), (double) (var15 + par5 * sizeFactor - par7 * sizeFactor), 0D, 0D);
   
}
 
Example 2
Source File: RenderAutoChisel.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	Tessellator tes = Tessellator.instance;
	IIcon icon = renderer.hasOverrideBlockTexture() ? renderer.overrideBlockTexture : block.getIcon(0, 0);
	tes.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
	tes.setColorOpaque_F(1, 1, 1);
	tes.addTranslation(x, y, z + 1);
	for (GroupObject go : model.groupObjects) {
		for (Face f : go.faces) {
			Vertex n = f.faceNormal;
			tes.setNormal(n.x, n.y, n.z);
			for (int i = 0; i < f.vertices.length; i++) {
				Vertex vert = f.vertices[i];
				TextureCoordinate t = f.textureCoordinates[i];
				if (!renderer.hasOverrideBlockTexture()) {
					tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU(t.u * 16), icon.getInterpolatedV(t.v * 16));
				} else {
					tes.addVertexWithUV(vert.x, vert.y, vert.z, icon.getInterpolatedU((t.u * 64) % 16), icon.getInterpolatedV((t.v * 64) % 16));
				}
			}
		}
	}
	tes.addTranslation(-x, -y, -z - 1);
	return true;
}
 
Example 3
Source File: MoCEntityFXVanish.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderParticle(Tessellator par1Tessellator, float par2, float par3, float par4, float par5, float par6, float par7)
{
    //func_98187_b() = bindTexture();
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(MoCreatures.proxy.MISC_TEXTURE + "fxvanish.png");
    float scale = 0.1F * this.particleScale;
    float xPos = (float) (this.prevPosX + (this.posX - this.prevPosX) * (double) par2 - interpPosX);
    float yPos = (float) (this.prevPosY + (this.posY - this.prevPosY) * (double) par2 - interpPosY);
    float zPos = (float) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) par2 - interpPosZ);
    float colorIntensity = 1.0F;
    par1Tessellator.setColorOpaque_F(this.particleRed * colorIntensity, this.particleGreen * colorIntensity, this.particleBlue * colorIntensity);//, 1.0F);

    par1Tessellator.addVertexWithUV((double) (xPos - par3 * scale - par6 * scale), (double) (yPos - par4 * scale), (double) (zPos - par5 * scale - par7 * scale), 0D, 1D);
    par1Tessellator.addVertexWithUV((double) (xPos - par3 * scale + par6 * scale), (double) (yPos + par4 * scale), (double) (zPos - par5 * scale + par7 * scale), 1D, 1D);
    par1Tessellator.addVertexWithUV((double) (xPos + par3 * scale + par6 * scale), (double) (yPos + par4 * scale), (double) (zPos + par5 * scale + par7 * scale), 1D, 0D);
    par1Tessellator.addVertexWithUV((double) (xPos + par3 * scale - par6 * scale), (double) (yPos - par4 * scale), (double) (zPos + par5 * scale - par7 * scale), 0D, 0D);

    
}
 
Example 4
Source File: RenderHelperLL.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderXYZUVAO (int[][] index) {
    Tessellator tessellator = Tessellator.instance;

    int[] tl = index[TL];
    int[] bl = index[BL];
    int[] br = index[BR];
    int[] tr = index[TR];

    tessellator.setColorOpaque_F(state.colorTopLeft[0], state.colorTopLeft[1], state.colorTopLeft[2]);
    tessellator.setBrightness(state.brightnessTopLeft);
    tessellator.addVertexWithUV(xyz[tl[0]], xyz[tl[1]], xyz[tl[2]], uv[tl[3]], uv[tl[4]]);

    tessellator.setColorOpaque_F(state.colorBottomLeft[0], state.colorBottomLeft[1], state.colorBottomLeft[2]);
    tessellator.setBrightness(state.brightnessBottomLeft);
    tessellator.addVertexWithUV(xyz[bl[0]], xyz[bl[1]], xyz[bl[2]], uv[bl[3]], uv[bl[4]]);

    tessellator.setColorOpaque_F(state.colorBottomRight[0], state.colorBottomRight[1], state.colorBottomRight[2]);
    tessellator.setBrightness(state.brightnessBottomRight);
    tessellator.addVertexWithUV(xyz[br[0]], xyz[br[1]], xyz[br[2]], uv[br[3]], uv[br[4]]);

    tessellator.setColorOpaque_F(state.colorTopRight[0], state.colorTopRight[1], state.colorTopRight[2]);
    tessellator.setBrightness(state.brightnessTopRight);
    tessellator.addVertexWithUV(xyz[tr[0]], xyz[tr[1]], xyz[tr[2]], uv[tr[3]], uv[tr[4]]);
}
 
Example 5
Source File: BlockExtendedNodeJarRenderer.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private int setBrightness(IBlockAccess blockAccess, int i, int j, int k, Block block) {
    Tessellator tessellator = Tessellator.instance;
    int mb = block.getMixedBrightnessForBlock(blockAccess, i, j, k);
    tessellator.setBrightness(mb);

    float f = 1.0F;

    int l = block.colorMultiplier(blockAccess, i, j, k);
    float f1 = (l >> 16 & 0xFF) / 255.0F;
    float f2 = (l >> 8 & 0xFF) / 255.0F;
    float f3 = (l & 0xFF) / 255.0F;
    if (EntityRenderer.anaglyphEnable) {
        float f6 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f4 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        float f7 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f6;
        f2 = f4;
        f3 = f7;
    }
    tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);
    return mb;
}
 
Example 6
Source File: BiomesOPlenty.java    From GardenCollection with MIT License 6 votes vote down vote up
@Override
public void render (IBlockAccess world, int x, int y, int z, RenderBlocks renderer, Block block, int meta, int height, AxisAlignedBB[] bounds) {
    crossRender.render(world, x, y, z, renderer, block, meta, height, bounds);

    if (meta != 3 || height > 1)
        return;

    IIcon hedgeTrunk = renderer.minecraftRB.getTextureMapBlocks().getTextureExtry("biomesoplenty:hedge_trunk");
    if (hedgeTrunk == null)
        return;

    Tessellator tesselator = Tessellator.instance;
    tesselator.setColorOpaque_F(1, 1, 1);

    renderer.drawCrossedSquares(hedgeTrunk, x, y, z, 1.0F);
}
 
Example 7
Source File: FlowerLeafRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockFlowerLeaves block, int modelId, RenderBlocks renderer) {
    renderer.renderStandardBlock(block, x, y, z);

    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
    tessellator.setColorOpaque_F(1f, 1f, 1f);

    int meta = world.getBlockMetadata(x, y, z);
    float offset = .03125f;
    IIcon icon = block.getFlowerIcon(world, x, y, z, meta, 1);
    if (icon != null)
        renderer.renderFaceYPos(block, x, y + offset, z, icon);

    icon = block.getFlowerIcon(world, x, y, z, meta, 2);
    if (icon != null)
        renderer.renderFaceZNeg(block, x, y, z - offset, icon);

    icon = block.getFlowerIcon(world, x, y, z, meta, 3);
    if (icon != null)
        renderer.renderFaceZPos(block, x, y, z + offset, icon);

    icon = block.getFlowerIcon(world, x, y, z, meta, 4);
    if (icon != null)
        renderer.renderFaceXNeg(block, x - offset, y, z, icon);

    icon = block.getFlowerIcon(world, x, y, z, meta, 5);
    if (icon != null)
        renderer.renderFaceXPos(block, x + offset, y, z, icon);

    return true;
}
 
Example 8
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean renderCrossedSquares(IBlockAccess world, RenderBlocks renderer, Block block, int x, int y, int z, TileEntityGarden te)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    //if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
    //    l = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);
    double d1 = (double)x;
    double d2 = (double)y;
    double d0 = (double)z;
    long i1;

    IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, renderer.blockAccess.getBlockMetadata(x, y, z));
    renderer.drawCrossedSquares(iicon, d1, d2, d0, 1.0F);
    return true;
}
 
Example 9
Source File: RenderLaserSource.java    From Artifacts with MIT License 5 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	int l = 1;
	if(world != null)
		l = world.getBlockMetadata(x, y, z);
	IIcon laser = block.getIcon(0,0);
	Tessellator tessellator = Tessellator.instance;
	tessellator.setBrightness(15728880);
	tessellator.setColorOpaque_F(1, 1, 1);
       float f = 1F - 1F/128F;
       renderer.renderMaxX = 1;
       renderer.renderMinX = 0;
       renderer.renderMaxY = 1;
       renderer.renderMinY = 0;
       renderer.renderMaxZ = 1;
       renderer.renderMinZ = 0;
	switch(l&3) {
		case 0:
			renderer.renderFaceZPos(Blocks.ice, x, y, z-f, laser);
			break;
		case 1:
			renderer.renderFaceXNeg(Blocks.ice, x+f, y, z, laser);
			break;
		case 2:
			renderer.renderFaceZNeg(Blocks.ice, x, y, z+f, laser);
			break;
		case 3:
			renderer.renderFaceXPos(Blocks.ice, x-f, y, z, laser);
			break;
	}
	if(world != null)
		renderer.renderBlockAllFaces(BlockLaserBeam.instance, x, y, z);
	return true;
}
 
Example 10
Source File: RenderHelper.java    From GardenCollection with MIT License 5 votes vote down vote up
private void setupColorMult (int face, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    float[] norm = normMap[face];
    float scale = state.getColorMult(face);

    tessellator.setColorOpaque_F(scale * r, scale * g, scale * b);
    tessellator.startDrawingQuads();
    tessellator.setNormal(norm[0], norm[1], norm[2]);

    state.enableAO = false;
}
 
Example 11
Source File: RenderHelper.java    From GardenCollection with MIT License 5 votes vote down vote up
private void setupColorMult (int face, IBlockAccess blockAccess, Block block, int x, int y, int z, float r, float g, float b) {
    Tessellator tessellator = Tessellator.instance;
    float[] norm = normMap[face];
    float scale = state.getColorMult(face);

    if (blockAccess == null) {
        tessellator.startDrawingQuads();
        tessellator.setColorOpaque_F(r, g, b);
        tessellator.setNormal(norm[0], norm[1], norm[2]);
    }
    else {
        int brightX = x;
        int brightY = y;
        int brightZ = z;

        switch (face) {
            case YNEG: brightY = (state.renderMinY > 0) ? y : y - 1; break;
            case YPOS: brightY = (state.renderMaxY < 1) ? y : y + 1; break;
            case ZNEG: brightZ = (state.renderMinZ > 0) ? z : z - 1; break;
            case ZPOS: brightZ = (state.renderMaxZ < 1) ? z : z + 1; break;
            case XNEG: brightX = (state.renderMinX > 0) ? x : x - 1; break;
            case XPOS: brightX = (state.renderMaxX < 1) ? x : x + 1; break;
        }

        tessellator.setColorOpaque_F(scale * r, scale * g, scale * b);
        tessellator.setBrightness(block.getMixedBrightnessForBlock(blockAccess, brightX, brightY, brightZ));
    }

    state.enableAO = false;
}
 
Example 12
Source File: RenderHelper.java    From GardenCollection with MIT License 4 votes vote down vote up
public static void setTessellatorColor (Tessellator tessellator, float[] color) {
    tessellator.setColorOpaque_F(color[0], color[1], color[2]);
}
 
Example 13
Source File: BlockRoadLineRenderer.java    From Chisel with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer)
{
    int meta = world.getBlockMetadata(x, y, z);
    BlockRoadLine block = (BlockRoadLine) b;
    Tessellator tessellator = Tessellator.instance;

    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    float f = 1.0F;
    int i1 = block.colorMultiplier(world, x, y, z);
    float f1 = (i1 >> 16 & 255) / 255.0F;
    float f2 = (i1 >> 8 & 255) / 255.0F;
    float f3 = (i1 & 255) / 255.0F;

    if(EntityRenderer.anaglyphEnable)
    {
        float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
        float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
        float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
        f1 = f4;
        f2 = f5;
        f3 = f6;
    }
    tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);

    boolean N = world.getBlock(x, y, z - 1).equals(block);
    boolean S = world.getBlock(x, y, z + 1).equals(block);
    boolean W = world.getBlock(x - 1, y, z).equals(block);
    boolean E = world.getBlock(x + 1, y, z).equals(block);

    if(!N && !S && !W && !E)
    {
        renderer.renderStandardBlock(block, x, y, z);
        return true;
    }

    if(N && S)
    {
        renderer.uvRotateTop = 0;
        renderer.overrideBlockTexture = block.fullLineIcon;
        renderer.renderStandardBlock(block, x, y, z);

    } else
    {
        if(N)
        {
            renderer.uvRotateTop = 0;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
        if(S)
        {
            renderer.uvRotateTop = 3;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }

    }

    if(E && W)
    {
        renderer.uvRotateTop = 1;
        renderer.overrideBlockTexture = block.fullLineIcon;
        renderer.renderStandardBlock(block, x, y, z);
    } else
    {
        if(E)
        {
            renderer.uvRotateTop = 1;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
        if(W)
        {
            renderer.uvRotateTop = 2;
            renderer.overrideBlockTexture = block.halfLineIcon;
            renderer.renderStandardBlock(block, x, y, z);
        }
    }

    renderer.uvRotateTop = 0;
    renderer.overrideBlockTexture = null;
    return true;
}
 
Example 14
Source File: RenderBlockGauge.java    From archimedes-ships with MIT License 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer)
{
	Tessellator tessellator = Tessellator.instance;
	int l = world.getBlockMetadata(x, y, z);
	IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, l);
	int dir = l & 3;
	
	tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
	tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
	double u0 = iicon.getMinU();
	double v0 = iicon.getMinV();
	double u1 = iicon.getMaxU();
	double v1 = iicon.getMaxV();
	double yoffset = 0.0625D;
	double dx = x + 1;
	double dz = z + 1;
	double dy = y + yoffset;
	
	switch (dir)
	{
	case 0:
		tessellator.addVertexWithUV(x, dy, z, u1, v1);
		tessellator.addVertexWithUV(x, dy, dz, u1, v0);
		tessellator.addVertexWithUV(dx, dy, dz, u0, v0);
		tessellator.addVertexWithUV(dx, dy, z, u0, v1);
		break;
	case 1:
		tessellator.addVertexWithUV(x, dy, z, u1, v0);
		tessellator.addVertexWithUV(x, dy, dz, u0, v0);
		tessellator.addVertexWithUV(dx, dy, dz, u0, v1);
		tessellator.addVertexWithUV(dx, dy, z, u1, v1);
		break;
	case 2:
		tessellator.addVertexWithUV(x, dy, z, u0, v0);
		tessellator.addVertexWithUV(x, dy, dz, u0, v1);
		tessellator.addVertexWithUV(dx, dy, dz, u1, v1);
		tessellator.addVertexWithUV(dx, dy, z, u1, v0);
		break;
	case 3:
	default:
		tessellator.addVertexWithUV(x, dy, z, u0, v1);
		tessellator.addVertexWithUV(x, dy, dz, u1, v1);
		tessellator.addVertexWithUV(dx, dy, dz, u1, v0);
		tessellator.addVertexWithUV(dx, dy, z, u0, v0);
	}
	return true;
}
 
Example 15
Source File: LightChainRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockLightChain block, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    int color = block.colorMultiplier(world, x, y, z);
    float r = (float)(color >> 16 & 255) / 255f;
    float g = (float)(color >> 8 & 255) / 255f;
    float b = (float)(color & 255) / 255f;

    tessellator.setColorOpaque_F(r, g, b);

    IIcon icon = block.getIcon(0, world.getBlockMetadata(x, y, z));
    if (renderer.hasOverrideBlockTexture())
        icon = renderer.overrideBlockTexture;

    int yMin = block.findMinY(world, x, y, z);
    int yMax = block.findMaxY(world, x, y, z);

    double upperDepth = 0;
    double lowerDepth = 0;

    Block blockTop = world.getBlock(x, yMax + 1, z);
    if (blockTop instanceof IChainSingleAttachable) {
        Vec3 topAttach = ((IChainSingleAttachable) blockTop).getChainAttachPoint(world, x, yMax + 1, z, 0);
        if (topAttach != null)
            upperDepth = topAttach.yCoord;
    }

    if (upperDepth == 0) {
        IAttachable attachable = GardenAPI.instance().registries().attachable().getAttachable(blockTop, world.getBlockMetadata(x, y + 1, z));
        if (attachable != null && attachable.isAttachable(world, x, y + 1, z, 0))
            upperDepth = attachable.getAttachDepth(world, x, y + 1, z, 0);
    }

    for (Vec3 point : block.getAttachPoints(world, x, y, z)) {
        float height = yMax - yMin + 2 - (float)point.yCoord + (float)upperDepth;

        double cx = .5f;
        double cz = .5f;
        double dx = cx - point.xCoord;
        double dz = cz - point.zCoord;
        double yt = y + 1;
        double yb = y;

        double localYMin = yMin + point.yCoord - 1;

        if (y == yMin)
            yb = y - 1 + point.yCoord;
        if (y == yMax)
            yt = y + 1 + upperDepth;

        double lerpB = 1 - ((yb - localYMin) / height);
        double lerpT = 1 - ((yt - localYMin) / height);

        drawBetween(renderer, icon, x + dx * lerpB + cx, yb, z + dz * lerpB + cz, x + dx * lerpT + cx, yt, z + dz * lerpT + cz);
    }


    /*double lerpB = ((y - yMin) / height) * .5f;
    double lerpT = ((y + 1 - yMin) / height) * .5f;

    drawBetween(renderer, icon, .005 + x + lerpB, y, z + lerpB, x + lerpT, y + 1, z + lerpT);
    drawBetween(renderer, icon, .005 + x + 1 - lerpB, y, z + lerpB, x + 1 - lerpT, y + 1, z + lerpT);
    drawBetween(renderer, icon, .005 + x + lerpB, y, z + 1 - lerpB, x + lerpT, y + 1, z + 1 - lerpT);
    drawBetween(renderer, icon, .005 + x + 1 - lerpB, y, z + 1 - lerpB, x + 1 - lerpT, y + 1, z + 1 - lerpT);*/

    gardenProxyRenderer.renderWorldBlock(world, x, y, z, ModBlocks.gardenProxy, ModBlocks.gardenProxy.getRenderType(), renderer);

    return true;
}
 
Example 16
Source File: SmallFireRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockSmallFire block, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    IIcon icon0 = block.getFireIcon(0);
    IIcon icon1 = block.getFireIcon(1);
    IIcon icon2 = icon0;

    if (renderer.hasOverrideBlockTexture())
        icon2 = renderer.overrideBlockTexture;

    tessellator.setColorOpaque_F(1, 1, 1);
    tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

    double uMin = icon2.getMinU();
    double vMin = icon2.getMinV();
    double uMax = icon2.getMaxU();
    double vMax = icon2.getMaxV();

    double y0 = y - .0625;
    double y1 = y + 1;

    double x0 = x + .5 + .2;
    double x1 = x + .5 - .2;
    double x2 = x + .5 - .3;
    double x3 = x + .5 + .3;
    double z0 = z + .5 + .2;
    double z1 = z + .5 - .2;
    double z2 = z + .5 - .3;
    double z3 = z + .5 + .3;

    tessellator.addVertexWithUV(x2, y1, z + 1 - .0625f, uMax, vMin);
    tessellator.addVertexWithUV(x0, y0, z + 1 - .0625f, uMax, vMax);
    tessellator.addVertexWithUV(x0, y0, z + 0 + .0625f, uMin, vMax);
    tessellator.addVertexWithUV(x2, y1, z + 0 + .0625f, uMin, vMin);

    tessellator.addVertexWithUV(x3, y1, z + 0 + .0625f, uMax, vMin);
    tessellator.addVertexWithUV(x1, y0, z + 0 + .0625f, uMax, vMax);
    tessellator.addVertexWithUV(x1, y0, z + 1 - .0625f, uMin, vMax);
    tessellator.addVertexWithUV(x3, y1, z + 1 - .0625f, uMin, vMin);

    uMin = icon1.getMinU();
    vMin = icon1.getMinV();
    uMax = icon1.getMaxU();
    vMax = icon1.getMaxV();

    tessellator.addVertexWithUV(x + 1 - .0625f, y1, z3, uMax, vMin);
    tessellator.addVertexWithUV(x + 1 - .0625f, y0, z1, uMax, vMax);
    tessellator.addVertexWithUV(x + 0 + .0625f, y0, z1, uMin, vMax);
    tessellator.addVertexWithUV(x + 0 + .0625f, y1, z3, uMin, vMin);

    tessellator.addVertexWithUV(x + 0 + .0625f, y1, z2, uMax, vMin);
    tessellator.addVertexWithUV(x + 0 + .0625f, y0, z0, uMax, vMax);
    tessellator.addVertexWithUV(x + 1 - .0625f, y0, z0, uMin, vMax);
    tessellator.addVertexWithUV(x + 1 - .0625f, y1, z2, uMin, vMin);

    x0 = x + .5 - .5 + .125f;
    x1 = x + .5 + .5 - .125f;
    x2 = x + .5 - .4 + .125f;
    x3 = x + .5 + .4 - .125f;
    z0 = z + .5 - .5 + .125f;
    z1 = z + .5 + .5 - .125f;
    z2 = z + .5 - .4 + .125f;
    z3 = z + .5 + .4 - .125f;

    tessellator.addVertexWithUV(x2, y1, z + 0, uMax, vMin);
    tessellator.addVertexWithUV(x0, y0, z + 0, uMax, vMax);
    tessellator.addVertexWithUV(x0, y0, z + 1, uMin, vMax);
    tessellator.addVertexWithUV(x2, y1, z + 1, uMin, vMin);

    tessellator.addVertexWithUV(x3, y1, z + 1, uMax, vMin);
    tessellator.addVertexWithUV(x1, y0, z + 1, uMax, vMax);
    tessellator.addVertexWithUV(x1, y0, z + 0, uMin, vMax);
    tessellator.addVertexWithUV(x3, y1, z + 0, uMin, vMin);

    uMin = icon0.getMinU();
    vMin = icon0.getMinV();
    uMax = icon0.getMaxU();
    vMax = icon0.getMaxV();

    tessellator.addVertexWithUV(x + 0, y1, z3, uMax, vMin);
    tessellator.addVertexWithUV(x + 0, y0, z1, uMax, vMax);
    tessellator.addVertexWithUV(x + 1, y0, z1, uMin, vMax);
    tessellator.addVertexWithUV(x + 1, y1, z3, uMin, vMin);

    tessellator.addVertexWithUV(x + 1, y1, z2, uMax, vMin);
    tessellator.addVertexWithUV(x + 1, y0, z0, uMax, vMax);
    tessellator.addVertexWithUV(x + 0, y0, z0, uMin, vMax);
    tessellator.addVertexWithUV(x + 0, y1, z2, uMin, vMin);

    return true;
}
 
Example 17
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderBlockDoublePlant(IBlockAccess world, RenderBlocks renderer, BlockDoublePlant block, int x, int y, int z, TileEntityGarden potData)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    //if (l == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
    //    l = ColorizerGrass.getGrassColor(potData.getBiomeTemperature(), potData.getBiomeHumidity());

    float f = (float)(l >> 16 & 255) / 255.0F;
    float f1 = (float)(l >> 8 & 255) / 255.0F;
    float f2 = (float)(l & 255) / 255.0F;

    if (EntityRenderer.anaglyphEnable)
    {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    tessellator.setColorOpaque_F(f, f1, f2);
    long j1 = (long)(x * 3129871) ^ (long)z * 116129781L;
    j1 = j1 * j1 * 42317861L + j1 * 11L;
    double d19 = (double)x;
    double d0 = (double)y;
    double d1 = (double)z;
    //d19 += ((double)((float)(j1 >> 16 & 15L) / 15.0F) - 0.5D) * 0.3D;
    //d1 += ((double)((float)(j1 >> 24 & 15L) / 15.0F) - 0.5D) * 0.3D;
    int i1 = renderer.blockAccess.getBlockMetadata(x, y, z);
    boolean flag = false;
    boolean flag1 = BlockDoublePlant.func_149887_c(i1);
    int k1;

    if (flag1)
    {
        k1 = BlockDoublePlant.func_149890_d(renderer.blockAccess.getBlockMetadata(x, y - 1, z));
    }
    else
    {
        k1 = BlockDoublePlant.func_149890_d(i1);
    }

    IIcon iicon = block.func_149888_a(flag1, k1);
    renderer.drawCrossedSquares(iicon, d19, d0, d1, 1.0F);

    if (flag1 && k1 == 0)
    {
        IIcon iicon1 = block.sunflowerIcons[0];
        double d2 = Math.cos((double)j1 * 0.8D) * Math.PI * 0.1D;
        double d3 = Math.cos(d2);
        double d4 = Math.sin(d2);
        double d5 = (double)iicon1.getMinU();
        double d6 = (double)iicon1.getMinV();
        double d7 = (double)iicon1.getMaxU();
        double d8 = (double)iicon1.getMaxV();
        double d9 = 0.3D;
        double d10 = -0.05D;
        double d11 = 0.5D + 0.3D * d3 - 0.5D * d4;
        double d12 = 0.5D + 0.5D * d3 + 0.3D * d4;
        double d13 = 0.5D + 0.3D * d3 + 0.5D * d4;
        double d14 = 0.5D + -0.5D * d3 + 0.3D * d4;
        double d15 = 0.5D + -0.05D * d3 + 0.5D * d4;
        double d16 = 0.5D + -0.5D * d3 + -0.05D * d4;
        double d17 = 0.5D + -0.05D * d3 - 0.5D * d4;
        double d18 = 0.5D + 0.5D * d3 + -0.05D * d4;
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d5, d8);
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d7, d8);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d7, d6);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d5, d6);
        IIcon iicon2 = block.sunflowerIcons[1];
        d5 = (double)iicon2.getMinU();
        d6 = (double)iicon2.getMinV();
        d7 = (double)iicon2.getMaxU();
        d8 = (double)iicon2.getMaxV();
        tessellator.addVertexWithUV(d19 + d17, d0 + 1.0D, d1 + d18, d5, d8);
        tessellator.addVertexWithUV(d19 + d15, d0 + 1.0D, d1 + d16, d7, d8);
        tessellator.addVertexWithUV(d19 + d13, d0 + 0.0D, d1 + d14, d7, d6);
        tessellator.addVertexWithUV(d19 + d11, d0 + 0.0D, d1 + d12, d5, d6);
    }

    return true;
}
 
Example 18
Source File: GardenProxyRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockGardenProxy block, int modelId, RenderBlocks renderer) {
    TileEntityGarden te = block.getGardenEntity(world, x, y, z);
    BlockGarden garden = block.getGardenBlock(world, x, y, z);
    if (te == null || garden == null)
        return true;

    int section = y - te.yCoord;

    Tessellator tessellator = Tessellator.instance;

    for (int slot : garden.getSlotProfile().getPlantSlots()) {
        Block subBlock = block.getPlantBlockRestricted(te, slot);
        int subBlockData = block.getPlantData(te, slot);
        if (subBlock == null)
            continue;

        block.bindSlot(te.getWorldObj(), x, y, z, te, slot);

        float offsetX = block.getPlantOffsetX(world, x, y, z, slot);
        float offsetY = block.getPlantOffsetY(world, x, y, z, slot);
        float offsetZ = block.getPlantOffsetZ(world, x, y, z, slot);

        AxisAlignedBB[] clippingBounds = garden.getSlotProfile().getClippingBounds(world, x, te.yCoord, z, slot);

        int color = subBlock.colorMultiplier(world, x, y, z);
        if (color == world.getBiomeGenForCoords(x, z).getBiomeGrassColor(x, y, z))
            color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

        float r = (color >> 16 & 255) / 255f;
        float g = (color >> 8 & 255) / 255f;
        float b = (color & 255) / 255f;

        if (EntityRenderer.anaglyphEnable) {
            float gray = (r * 30.0F + g * 59.0F + b * 11.0F) / 100.0F;
            float ra = (r * 30.0F + g * 70.0F) / 100.0F;
            float ba = (r * 30.0F + b * 70.0F) / 100.0F;
            r = gray;
            g = ra;
            b = ba;
        }

        tessellator.setColorOpaque_F(r, g, b);
        tessellator.setBrightness(subBlock.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));

        tessellator.addTranslation(offsetX, offsetY, offsetZ);

        try {
            IPlantRenderer plantRenderer = PlantRegistry.instance().getPlantRenderer(subBlock, subBlockData);
            if (plantRenderer != null) {
                IPlantMetaResolver resolver = PlantRegistry.instance().getPlantMetaResolver(subBlock, subBlockData);
                boolean shouldRender = section == 1;
                if (resolver != null && section <= resolver.getPlantHeight(subBlock, subBlockData))
                    shouldRender = true;

                if (shouldRender)
                    plantRenderer.render(world, x, y, z, renderer, subBlock, subBlockData, section, clippingBounds);
            }
            else
                renderer.renderBlockByRenderType(subBlock, x, y, z);
        }
        catch (Exception e) {
            continue;
        }
        finally {
            block.unbindSlot(te.getWorldObj(), x, y, z, te);
            tessellator.addTranslation(-offsetX, -offsetY, -offsetZ);
        }
    }

    return true;
}
 
Example 19
Source File: RendererRoadLine.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block b, int modelId, RenderBlocks renderer) {
	int meta = world.getBlockMetadata(x, y, z);
	BlockRoadLine block = (BlockRoadLine) b;
	Tessellator tessellator = Tessellator.instance;

	tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));

	float f = 1.0F;
	int i1 = block.colorMultiplier(world, x, y, z);
	float f1 = (i1 >> 16 & 255) / 255.0F;
	float f2 = (i1 >> 8 & 255) / 255.0F;
	float f3 = (i1 & 255) / 255.0F;

	if (EntityRenderer.anaglyphEnable) {
		float f4 = (f1 * 30.0F + f2 * 59.0F + f3 * 11.0F) / 100.0F;
		float f5 = (f1 * 30.0F + f2 * 70.0F) / 100.0F;
		float f6 = (f1 * 30.0F + f3 * 70.0F) / 100.0F;
		f1 = f4;
		f2 = f5;
		f3 = f6;
	}
	tessellator.setColorOpaque_F(f * f1, f * f2, f * f3);

	boolean N = world.getBlock(x, y, z - 1).equals(block) && world.getBlockMetadata(x, y, z - 1) == meta;
	boolean S = world.getBlock(x, y, z + 1).equals(block) && world.getBlockMetadata(x, y, z + 1) == meta;
	boolean W = world.getBlock(x - 1, y, z).equals(block) && world.getBlockMetadata(x - 1, y, z) == meta;
	boolean E = world.getBlock(x + 1, y, z).equals(block) && world.getBlockMetadata(x + 1, y, z) == meta;

	if (!N && !S && !W && !E) {
		renderer.renderStandardBlock(block, x, y, z);
		return true;
	}

	if (N && S) {
		renderer.uvRotateTop = 0;
		renderer.overrideBlockTexture = block.fullLineIcon[meta];
		renderer.renderStandardBlock(block, x, y, z);

	} else {
		if (N) {
			renderer.uvRotateTop = 0;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
		if (S) {
			renderer.uvRotateTop = 3;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}

	}

	if (E && W) {
		renderer.uvRotateTop = 1;
		renderer.overrideBlockTexture = block.fullLineIcon[meta];
		renderer.renderStandardBlock(block, x, y, z);
	} else {
		if (E) {
			renderer.uvRotateTop = 1;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
		if (W) {
			renderer.uvRotateTop = 2;
			renderer.overrideBlockTexture = block.halfLineIcon[meta];
			renderer.renderStandardBlock(block, x, y, z);
		}
	}

	renderer.uvRotateTop = 0;
	renderer.overrideBlockTexture = null;
	return true;
}
 
Example 20
Source File: BlockDoorRenderer.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
	Tessellator tessellator = Tessellator.instance;
	int meta = world.getBlockMetadata(x, y, z);

	if ((meta & 8) != 0) {
		if (world.getBlock(x, y - 1, z) != block)
			return false;
	} else if (world.getBlock(x, y + 1, z) != block)
		return false;

	int brightness = block.getMixedBrightnessForBlock(world, x, y, z);

	tessellator.setBrightness(renderer.renderMinY > 0.0D ? brightness : block.getMixedBrightnessForBlock(world, x, y - 1, z));
	tessellator.setColorOpaque_F(0.5F, 0.5F, 0.5F);
	renderer.renderFaceYNeg(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 0));

	if ((meta & 8) != 0) {
		tessellator.setBrightness(renderer.renderMaxY < 1.0D ? brightness : block.getMixedBrightnessForBlock(world, x, y + 1, z));
		tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
		renderer.uvRotateTop = 2;
		renderer.renderFaceYPos(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 1));
		renderer.uvRotateTop = 0;
	}

	tessellator.setBrightness(renderer.renderMinZ > 0.0D ? brightness : block.getMixedBrightnessForBlock(world, x, y, z - 1));
	tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
	renderer.renderFaceZNeg(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 2));

	renderer.flipTexture = false;
	tessellator.setBrightness(renderer.renderMaxZ < 1.0D ? brightness : block.getMixedBrightnessForBlock(world, x, y, z + 1));
	tessellator.setColorOpaque_F(0.8F, 0.8F, 0.8F);
	renderer.renderFaceZPos(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 3));

	renderer.flipTexture = false;
	tessellator.setBrightness(renderer.renderMinX > 0.0D ? brightness : block.getMixedBrightnessForBlock(world, x - 1, y, z));
	tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
	renderer.renderFaceXNeg(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 4));

	renderer.flipTexture = false;
	tessellator.setBrightness(renderer.renderMaxX < 1.0D ? brightness : block.getMixedBrightnessForBlock(world, x + 1, y, z));
	tessellator.setColorOpaque_F(0.6F, 0.6F, 0.6F);
	renderer.renderFaceXPos(block, x, y, z, renderer.getBlockIcon(block, world, x, y, z, 5));

	renderer.flipTexture = false;
	return true;
}