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

The following examples show how to use net.minecraft.client.renderer.RenderBlocks#renderBlockByRenderType() . 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: BlockTexturedOreRenderer.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 blck, int modelId, RenderBlocks renderer) {
	if (blck == null || !(blck instanceof BlockTexturedOre))
		return false;
	BlockTexturedOre block = (BlockTexturedOre) blck;

	if (block.currentPass == 0) {
		if (block.icon != null) {
			renderer.overrideBlockTexture = block.icon;
			renderer.renderStandardBlock(block, x, y, z);
			renderer.overrideBlockTexture = null;
		} else if (block.base != null) {
			renderer.renderBlockByRenderType(block.base, x, y, z);
		}
	} else {
		renderer.setRenderBounds(bot, bot, bot, top, top, top);
		renderer.renderStandardBlock(block, x, y, z);
	}

	return true;
}
 
Example 2
Source File: RendererMultiLayer.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 blck, int modelId, RenderBlocks renderer) {
	if (blck == null || !(blck instanceof BlockMultiLayerBase))
		return false;
	BlockMultiLayerBase block = (BlockMultiLayerBase) blck;

	if (MinecraftForgeClient.getRenderPass() == 0) {
		if (block.icon != null) {
			renderer.overrideBlockTexture = block.icon;
			renderer.renderStandardBlock(block, x, y, z);
			renderer.overrideBlockTexture = null;
			return true;
		} else if (block.base != null) {
			renderer.renderBlockByRenderType(block.base, x, y, z);
			return true;
		}
	} else {
		renderer.setRenderBounds(0, 0, 0, 1, 1, 1);
		return renderer.renderStandardBlock(block, x, y, z);
	}

	return false;
}
 
Example 3
Source File: BlockTexturedOreRenderer.java    From Chisel 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 blck, int modelId, RenderBlocks renderer)
{
    if(blck == null || !(blck instanceof BlockTexturedOre))
        return false;
    BlockTexturedOre block = (BlockTexturedOre) blck;

    if(block.currentPass == 0)
    {
        if(block.icon != null)
        {
            renderer.overrideBlockTexture = block.icon;
            renderer.renderStandardBlock(block, x, y, z);
            renderer.overrideBlockTexture = null;
        } else if(block.base != null)
        {
            renderer.renderBlockByRenderType(block.base, x, y, z);
        }
    } else
    {
        renderer.setRenderBounds(bot, bot, bot, top, top, top);
        renderer.renderStandardBlock(block, x, y, z);
    }

    return true;
}
 
Example 4
Source File: BlockTexturedOreRenderer.java    From Chisel 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 blck, int modelId, RenderBlocks renderer)
{
    if(blck == null || !(blck instanceof BlockTexturedOre))
        return false;
    BlockTexturedOre block = (BlockTexturedOre) blck;

    if(block.currentPass == 0)
    {
        if(block.icon != null)
        {
            renderer.overrideBlockTexture = block.icon;
            renderer.renderStandardBlock(block, x, y, z);
            renderer.overrideBlockTexture = null;
        } else if(block.base != null)
        {
            renderer.renderBlockByRenderType(block.base, x, y, z);
        }
    } else
    {
        renderer.setRenderBounds(bot, bot, bot, top, top, top);
        renderer.renderStandardBlock(block, x, y, z);
    }

    return true;
}
 
Example 5
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;
}