Java Code Examples for net.minecraft.client.renderer.RenderBlocks#hasOverrideBlockTexture()

The following examples show how to use net.minecraft.client.renderer.RenderBlocks#hasOverrideBlockTexture() . 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: 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 2
Source File: HeavyChainRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private void drawCrossedSquares(RenderBlocks renderer, IIcon icon, double x, double y, double z, float scale)
{
    Tessellator tessellator = Tessellator.instance;
    if (renderer.hasOverrideBlockTexture())
        icon = renderer.overrideBlockTexture;

    double uMin = icon.getInterpolatedU(renderer.renderMinX * 16.0D);
    double uMax = icon.getInterpolatedU(renderer.renderMaxX * 16.0D);
    double vMin = icon.getInterpolatedV(16 - renderer.renderMaxY * 16.0D);
    double vMax = icon.getInterpolatedV(16 - renderer.renderMinY * 16.0D);

    double d7 = 0.45D * (double)scale;
    double xMin = x + 0.5D - d7;
    double xMax = x + 0.5D + d7;
    double yMin = y + renderer.renderMinY * scale;
    double yMax = y + renderer.renderMaxY * scale;
    double zMin = z + 0.5D - d7;
    double zMax = z + 0.5D + d7;

    tessellator.addVertexWithUV(xMin, yMax, zMin, uMin, vMin);
    tessellator.addVertexWithUV(xMin, yMin, zMin, uMin, vMax);
    tessellator.addVertexWithUV(xMax, yMin, zMax, uMax, vMax);
    tessellator.addVertexWithUV(xMax, yMax, zMax, uMax, vMin);
    tessellator.addVertexWithUV(xMax, yMax, zMax, uMin, vMin);
    tessellator.addVertexWithUV(xMax, yMin, zMax, uMin, vMax);
    tessellator.addVertexWithUV(xMin, yMin, zMin, uMax, vMax);
    tessellator.addVertexWithUV(xMin, yMax, zMin, uMax, vMin);

    tessellator.addVertexWithUV(xMin, yMax, zMax, uMin, vMin);
    tessellator.addVertexWithUV(xMin, yMin, zMax, uMin, vMax);
    tessellator.addVertexWithUV(xMax, yMin, zMin, uMax, vMax);
    tessellator.addVertexWithUV(xMax, yMax, zMin, uMax, vMin);
    tessellator.addVertexWithUV(xMax, yMax, zMin, uMin, vMin);
    tessellator.addVertexWithUV(xMax, yMin, zMin, uMin, vMax);
    tessellator.addVertexWithUV(xMin, yMin, zMax, uMax, vMax);
    tessellator.addVertexWithUV(xMin, yMax, zMax, uMax, vMin);
}
 
Example 3
Source File: BlockPIMRenderer.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, BlockPIM block, int modelId, RenderBlocks renderer) {
	renderer.setRenderBoundsFromBlock(block);
	renderer.renderStandardBlock(block, x, y, z);

	final boolean isBreaking = renderer.hasOverrideBlockTexture();
	if (!isBreaking) renderer.setOverrideBlockTexture(BlockPIM.Icons.black);

	final boolean hasPlayer = hasPlayer(world, x, y, z);
	setTopPartBounds(renderer, hasPlayer);
	renderer.renderStandardBlock(block, x, y, z);

	if (!isBreaking) renderer.clearOverrideBlockTexture();
	return true;
}
 
Example 4
Source File: BlockChestRenderer.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) {
	return renderer.hasOverrideBlockTexture() && renderer.renderStandardBlock(block, x, y, z);
}
 
Example 5
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 6
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;
}