Java Code Examples for net.minecraft.block.Block#colorMultiplier()

The following examples show how to use net.minecraft.block.Block#colorMultiplier() . 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: 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 2
Source File: BlockGardenProxy.java    From GardenCollection with MIT License 6 votes vote down vote up
@SideOnly(Side.CLIENT)
@Override
public int colorMultiplier (IBlockAccess blockAccess, int x, int y, int z) {
    int slot = GardenCore.proxy.getClientBindingStack(this).getSlot();
    TileEntityGarden te = getGardenEntity(blockAccess, x, y, z);
    if (te == null || slot == -1)
        return super.colorMultiplier(blockAccess, x, y, z);

    Block block = getPlantBlockRestricted(te, slot);
    if (block == null)
        return super.colorMultiplier(blockAccess, x, y, z);

    try {
        return block.colorMultiplier(blockAccess, x, y, z);
    }
    catch (Exception e) {
        return super.colorMultiplier(blockAccess, x, y, z);
    }
}
 
Example 3
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 4
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 5
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 6
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 7
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 8
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 9
Source File: RenderFakeBlock.java    From Artifacts 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) {
	float f = 0.03125F;
	float xn = 0F;
	float xp = 1F;
	float yn = 0F;
	float yp = 1F;
	float zn = 0F;
	float zp = 1F;
	if(!world.getBlock(x-1, y, z).isOpaqueCube()) {
		if(world.getBlock(x-1, y, z) != block)
			xn = f;
	}
	if(!world.getBlock(x+1, y, z).isOpaqueCube()) {
		if(world.getBlock(x+1, y, z) != block)
			xp = 1F-f;
	}
	if(!world.getBlock(x, y-1, z).isOpaqueCube()) {
		if(world.getBlock(x, y-1, z) != block)
			yn = f;
	}
	if(!world.getBlock(x, y+1, z).isOpaqueCube()) {
		if(world.getBlock(x, y+1, z) != block)
			yp = 1F-f;
	}
	if(!world.getBlock(x, y, z-1).isOpaqueCube()) {
		if(world.getBlock(x, y, z-1) != block)
			zn = f;
	}
	if(!world.getBlock(x, y, z+1).isOpaqueCube()) {
		if(world.getBlock(x, y, z+1) != block)
			zp = 1F-f;
	}
	//block.setBlockBounds(xn, yn, zn, xp, yp, zp);
	renderer.setRenderBounds(xn, yn, zn, xp, yp, zp);
	
	int l = block.colorMultiplier(world, x, y, z);
       float f0 = (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;
           f0 = f3;
           f1 = f4;
           f2 = f5;
       }
       
       //if() {
       /*f0 *= 1.5;
       f1 *= 1.5;
       f2 *= 1.5;*/
       //}

       return renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, f0, f1, f2);
}