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

The following examples show how to use net.minecraft.client.renderer.RenderBlocks#getBlockIconFromSideAndMetadata() . 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: DecorativePotRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderInventoryBlock (BlockDecorativePot block, int metadata, int modelId, RenderBlocks renderer) {
    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, metadata);

    float unit = .0625f;
    boxRenderer.setIcon(icon);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);

    GL11.glRotatef(90, 0, 1, 0);
    GL11.glTranslatef(-.5f, -.5f, -.5f);

    boxRenderer.renderBox(null, block, 0, 0, 0, 0, 14 * unit, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS);
    boxRenderer.renderBox(null, block, 0, 0, 0, 1 * unit, 8 * unit, 1 * unit, 15 * unit, 16 * unit, 15 * unit, 0, ModularBoxRenderer.CUT_YPOS);

    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 3 * unit, 6 * unit, 3 * unit, 13 * unit, 8 * unit, 13 * unit);
    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 5 * unit, 3 * unit, 5 * unit, 11 * unit, 6 * unit, 11 * unit);
    boxRenderer.renderSolidBox(null, block, 0, 0, 0, 2 * unit, 0 * unit, 2 * unit, 14 * unit, 3 * unit, 14 * unit);

    GL11.glTranslatef(.5f, .5f, .5f);
}
 
Example 2
Source File: MediumPotRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderInventoryBlock (BlockMediumPot block, int metadata, int modelId, RenderBlocks renderer) {
    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, metadata & 15);

    boolean blendEnabled = GL11.glIsEnabled(GL11.GL_BLEND);
    if (blendEnabled)
        GL11.glDisable(GL11.GL_BLEND);

    boxRenderer.setUnit(.0625);
    boxRenderer.setIcon(icon);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);

    GL11.glRotatef(90, 0, 1, 0);
    GL11.glTranslatef(-.5f, -.5f, -.5f);

    boxRenderer.renderBox(null, block, 0, 0, 0, .125, 0, .125, .875, .75, .875, 0, ModularBoxRenderer.CUT_YPOS);

    if (!blendEnabled)
        GL11.glDisable(GL11.GL_BLEND);

    GL11.glTranslatef(.5f, .5f, .5f);
}
 
Example 3
Source File: CrossedSquaresPlantRenderer.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) {
    if (bounds == null)
        return;

    IPlantMetaResolver resolver = PlantRegistry.instance().getPlantMetaResolver(block, meta);
    if (resolver != null)
        meta = resolver.getPlantSectionMeta(block, meta, height);

    IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, meta);

    for (AxisAlignedBB bound : bounds) {
        RenderHelper.instance.setRenderBounds(bound.minX, bound.minY, bound.minZ, bound.maxX, bound.maxY, bound.maxZ);
        RenderHelper.instance.drawCrossedSquaresBounded(iicon, x, y, z, 1);
    }
}
 
Example 4
Source File: GroundCoverPlantRenderer.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) {
    IPlantMetaResolver resolver = PlantRegistry.instance().getPlantMetaResolver(block, meta);
    if (resolver != null)
        meta = resolver.getPlantSectionMeta(block, meta, height);

    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 0, meta);

    renderer.setRenderBounds(0, 0, 0, 1, .03125, 1);
    renderer.renderFaceYPos(block, x, y, z, icon);

    /*float f = 0.1F;
    double d0 = (double)icon.getMinU();
    double d1 = (double)icon.getMinV();
    double d2 = (double)icon.getMaxU();
    double d3 = (double)icon.getMaxV();

    float f1 = (float)x + 0.5F;
    float f2 = (float)z + 0.5F;
    float f3 = (float)(i1 & 1) * 0.5F * (float)(1 - i1 / 2 % 2 * 2);
    float f4 = (float)(i1 + 1 & 1) * 0.5F * (float)(1 - (i1 + 1) / 2 % 2 * 2);*/
}
 
Example 5
Source File: HeavyChainRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderCrossedSquares (RenderBlocks renderer, Block block, int x, int y, int z)
{
    Tessellator tessellator = Tessellator.instance;
    tessellator.setBrightness(block.getMixedBrightnessForBlock(renderer.blockAccess, x, y, z));
    int l = block.colorMultiplier(renderer.blockAccess, x, y, z);
    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);

    IIcon iicon = renderer.getBlockIconFromSideAndMetadata(block, 0, renderer.blockAccess.getBlockMetadata(x, y, z));
    drawCrossedSquares(renderer, iicon, x, y, z, 1.0F);
}
 
Example 6
Source File: WindowBoxRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private void renderInventoryBlock (BlockWindowBox block, int metadata, int modelId, RenderBlocks renderer) {
    Tessellator tessellator = Tessellator.instance;
    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, metadata);

    float unit = .0625f;
    boxRenderer.setIcon(icon);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);

    GL11.glRotatef(90, 0, 1, 0);
    GL11.glTranslatef(-.5f, -.5f, -.5f);

    boxRenderer.renderBox(null, block, 0, 0, 0, 0 * unit, 4 * unit, 4 * unit, 16 * unit, 12 * unit, 12 * unit, 0, ModularBoxRenderer.CUT_YPOS);

    GL11.glTranslatef(.5f, .5f, .5f);
}
 
Example 7
Source File: MediumPotRenderer.java    From GardenCollection with MIT License 5 votes vote down vote up
private boolean renderWorldBlockPass0 (IBlockAccess world, int x, int y, int z, BlockMediumPot block, int modelId, RenderBlocks renderer) {
    int metadata = world.getBlockMetadata(x, y, z);

    boxRenderer.setUnit(.0625);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
    for (int i = 0; i < 6; i++)
        boxRenderer.setIcon(renderer.getBlockIconFromSideAndMetadata(block, i, metadata), i);

    boxRenderer.renderBox(world, block, x, y, z, .125, 0, .125, .875, .75, .875, 0, ModularBoxRenderer.CUT_YPOS);

    TileEntityMediumPot te = block.getTileEntity(world, x, y, z);
    if (te != null && te.getSubstrate() != null && te.getSubstrate().getItem() instanceof ItemBlock) {
        Block substrate = Block.getBlockFromItem(te.getSubstrate().getItem());
        int substrateData = te.getSubstrate().getItemDamage();

        if (substrate != Blocks.water) {
            IIcon substrateIcon = renderer.getBlockIconFromSideAndMetadata(substrate, 1, substrateData);

            int color = substrate.colorMultiplier(world, x, y, z);
            if (color == Blocks.grass.colorMultiplier(world, x, y, z))
                color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

            RenderHelper.calculateBaseColor(colorScratch, color);

            RenderHelper.instance.setRenderBounds(.125, 0, .125, .875, .6875f, .875);
            RenderHelper.instance.renderFace(RenderHelper.YPOS, world, block, x, y, z, substrateIcon, colorScratch[0], colorScratch[1], colorScratch[2]);
        }
    }

    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: LargePotRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlockPass0 (IBlockAccess world, int x, int y, int z, BlockLargePot block, int modelId, RenderBlocks renderer) {
    int metadata = world.getBlockMetadata(x, y, z);

    boxRenderer.setUnit(.0625);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
    for (int i = 0; i < 6; i++)
        boxRenderer.setIcon(renderer.getBlockIconFromSideAndMetadata(block, i, metadata), i);

    TileEntityLargePot te = block.getTileEntity(world, x, y, z);

    int connectFlags = 0;
    connectFlags |= te.isAttachedNeighbor(x - 1, y, z - 1) ? ModularBoxRenderer.CONNECT_ZNEG_XNEG : 0;
    connectFlags |= te.isAttachedNeighbor(x, y, z - 1) ? ModularBoxRenderer.CONNECT_ZNEG : 0;
    connectFlags |= te.isAttachedNeighbor(x + 1, y, z - 1) ? ModularBoxRenderer.CONNECT_ZNEG_XPOS : 0;
    connectFlags |= te.isAttachedNeighbor(x - 1, y, z) ? ModularBoxRenderer.CONNECT_XNEG : 0;
    connectFlags |= te.isAttachedNeighbor(x + 1, y, z) ? ModularBoxRenderer.CONNECT_XPOS : 0;
    connectFlags |= te.isAttachedNeighbor(x - 1, y, z + 1) ? ModularBoxRenderer.CONNECT_ZPOS_XNEG : 0;
    connectFlags |= te.isAttachedNeighbor(x, y, z + 1) ? ModularBoxRenderer.CONNECT_ZPOS : 0;
    connectFlags |= te.isAttachedNeighbor(x + 1, y, z + 1) ? ModularBoxRenderer.CONNECT_ZPOS_XPOS : 0;

    boxRenderer.renderBox(world, block, x, y, z, 0, 0, 0, 1, 1, 1, connectFlags, ModularBoxRenderer.CUT_YPOS);

    if (te != null && te.getSubstrate() != null && te.getSubstrate().getItem() instanceof ItemBlock) {
        Block substrate = Block.getBlockFromItem(te.getSubstrate().getItem());
        int substrateData = te.getSubstrate().getItemDamage();

        if (substrate != Blocks.water) {
            IIcon substrateIcon = renderer.getBlockIconFromSideAndMetadata(substrate, 1, substrateData);

            int color = substrate.colorMultiplier(world, x, y, z);
            if (color == Blocks.grass.colorMultiplier(world, x, y, z))
                color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

            RenderHelper.calculateBaseColor(colorScratch, color);

            RenderHelper.instance.setRenderBounds(0, 0, 0, 1, 1 - .0625, 1);
            RenderHelper.instance.renderFace(RenderHelper.YPOS, world, block, x, y, z, substrateIcon, colorScratch[0], colorScratch[1], colorScratch[2]);
        }
    }

    return true;
}
 
Example 10
Source File: LargePotRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlockPass1 (IBlockAccess world, int x, int y, int z, BlockLargePot block, int modelId, RenderBlocks renderer) {
    TileEntityLargePot tileEntity = block.getTileEntity(world, x, y, z);
    if (tileEntity == null) {
        RenderHelper.instance.renderEmptyPlane(x, y, z);
        return true;
    }

    boolean didRender = false;

    IIcon icon = block.getOverlayIcon(tileEntity.getCarving());
    if (icon != null) {
        int connectFlags = 0;
        int cutFlags = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG;

        connectFlags |= tileEntity.isAttachedNeighbor(x, y, z - 1) ? ModularBoxRenderer.CONNECT_ZNEG : 0;
        connectFlags |= tileEntity.isAttachedNeighbor(x - 1, y, z) ? ModularBoxRenderer.CONNECT_XNEG : 0;
        connectFlags |= tileEntity.isAttachedNeighbor(x + 1, y, z) ? ModularBoxRenderer.CONNECT_XPOS : 0;
        connectFlags |= tileEntity.isAttachedNeighbor(x, y, z + 1) ? ModularBoxRenderer.CONNECT_ZPOS : 0;

        if (connectFlags != (ModularBoxRenderer.CONNECT_XNEG | ModularBoxRenderer.CONNECT_XPOS | ModularBoxRenderer.CONNECT_ZNEG | ModularBoxRenderer.CONNECT_ZPOS)) {
            boxRenderer.setUnit(0);
            boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);
            boxRenderer.setExteriorIcon(icon);

            boxRenderer.renderExterior(world, block, x, y, z, 0, 0, 0, 1, 1, 1, connectFlags, cutFlags);

            didRender = true;
        }
    }

    if (tileEntity.getSubstrate() != null && tileEntity.getSubstrate().getItem() instanceof ItemBlock) {
        Block substrate = Block.getBlockFromItem(tileEntity.getSubstrate().getItem());
        int substrateData = tileEntity.getSubstrate().getItemDamage();

        if (substrate == Blocks.water) {
            IIcon substrateIcon = renderer.getBlockIconFromSideAndMetadata(substrate, 1, substrateData);

            RenderHelper.instance.state.setRenderBounds(0, 0, 0, 1, 1 - .0625, 1);
            RenderHelper.instance.renderFace(RenderHelper.YPOS, world, block, x, y, z, substrateIcon);

            didRender = true;
        }
    }

    if (!didRender)
        RenderHelper.instance.renderEmptyPlane(x, y, z);

    return true;
}
 
Example 11
Source File: DecorativePotRenderer.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockDecorativePot block, int modelId, RenderBlocks renderer) {
    int data = world.getBlockMetadata(x, y, z);

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

    RenderHelper.calculateBaseColor(baseColor, block.colorMultiplier(world, x, y, z));

    float unit = .0625f;

    for (int i = 0; i < 6; i++)
        boxRenderer.setIcon(renderer.getBlockIconFromSideAndMetadata(block, i, data), i);

    boxRenderer.setColor(baseColor);
    boxRenderer.renderBox(world, block, x, y, z, 0, 14 * unit, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS);
    boxRenderer.setScaledColor(baseColor, .9375f);
    boxRenderer.renderBox(world, block, x, y, z, 1 * unit, 8 * unit, 1 * unit, 15 * unit, 16 * unit, 15 * unit, 0, ModularBoxRenderer.CUT_YPOS);

    boxRenderer.setScaledExteriorColor(baseColor, .875f);
    boxRenderer.renderSolidBox(world, block, x, y, z, 3 * unit, 6 * unit, 3 * unit, 13 * unit, 8 * unit, 13 * unit);
    boxRenderer.setScaledExteriorColor(baseColor, .8125f);
    boxRenderer.renderSolidBox(world, block, x, y, z, 5 * unit, 3 * unit, 5 * unit, 11 * unit, 6 * unit, 11 * unit);
    boxRenderer.setScaledExteriorColor(baseColor, .9375f);
    boxRenderer.setScaledExteriorColor(baseColor, .75f, 1);
    boxRenderer.renderSolidBox(world, block, x, y, z, 2 * unit, 0 * unit, 2 * unit, 14 * unit, 3 * unit, 14 * unit);

    TileEntityDecorativePot te = block.getTileEntity(world, x, y, z);
    ItemStack substrateItem = block.getGardenSubstrate(world, x, y, z, Slot2Profile.SLOT_CENTER);
    if (te != null && substrateItem != null && substrateItem.getItem() instanceof ItemBlock) {
        Block substrate = Block.getBlockFromItem(substrateItem.getItem());
        IIcon substrateIcon = renderer.getBlockIconFromSideAndMetadata(substrate, 1, substrateItem.getItemDamage());

        int color = substrate.colorMultiplier(world, x, y, z);
        if (color == Blocks.grass.colorMultiplier(world, x, y, z))
            color = ColorizerGrass.getGrassColor(te.getBiomeTemperature(), te.getBiomeHumidity());

        RenderHelper.calculateBaseColor(activeSubstrateColor, color);
        RenderHelper.scaleColor(activeSubstrateColor, activeSubstrateColor, .8f);

        RenderHelper.instance.setRenderBounds(.0625f, 0, .0625f, 1f - .0625f, 1f - .0625f, 1f - .0625f);
        RenderHelper.instance.renderFace(RenderHelper.YPOS, world, block, x, y, z, substrateIcon, activeSubstrateColor[0], activeSubstrateColor[1], activeSubstrateColor[2]);
    }

    return true;
}
 
Example 12
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 13
Source File: LargePotRenderer.java    From GardenCollection with MIT License 3 votes vote down vote up
private void renderInventoryBlock (BlockLargePot block, int metadata, int modelId, RenderBlocks renderer) {
    IIcon icon = renderer.getBlockIconFromSideAndMetadata(block, 1, metadata & 15);

    boolean blendEnabled = GL11.glIsEnabled(GL11.GL_BLEND);
    if (blendEnabled)
        GL11.glDisable(GL11.GL_BLEND);

    GL11.glDepthMask(true);

    boxRenderer.setUnit(.0625);
    boxRenderer.setIcon(icon);
    boxRenderer.setColor(ModularBoxRenderer.COLOR_WHITE);

    GL11.glRotatef(90, 0, 1, 0);
    GL11.glTranslatef(-.5f, -.5f, -.5f);

    boxRenderer.renderBox(null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, ModularBoxRenderer.CUT_YPOS);

    GL11.glEnable(GL11.GL_BLEND);

    if ((metadata & 0xFF00) != 0) {
        int cutFlags = ModularBoxRenderer.CUT_YPOS | ModularBoxRenderer.CUT_YNEG;

        boxRenderer.setUnit(0);
        boxRenderer.setIcon(block.getOverlayIcon((metadata >> 8) & 255));

        boxRenderer.renderExterior(null, block, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, cutFlags);
    }

    if (!blendEnabled)
        GL11.glDisable(GL11.GL_BLEND);

    GL11.glTranslatef(.5f, .5f, .5f);
}