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

The following examples show how to use net.minecraft.block.Block#getRenderColor() . 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: BlockColourGen.java    From mapwriter with MIT License 5 votes vote down vote up
private static int adjustBlockColourFromType(BlockColours bc, int blockAndMeta, int blockColour) {
	// for normal blocks multiply the block colour by the render colour.
	// for other blocks the block colour will be multiplied by the biome colour.
       int blockid = blockAndMeta >> 4;
	Block block = (Block) Block.blockRegistry.getObjectById(blockid);
	BlockType blockType = bc.getBlockType(blockAndMeta);
	switch (blockType) {
	
	case OPAQUE:
		blockColour |= 0xff000000;
	case NORMAL:
		// fix crash when mods don't implement getRenderColor for all
		// block meta values.
		try {
			int renderColour = block.getRenderColor(blockAndMeta & 0xf);
			if (renderColour != 0xffffff) {
				blockColour = Render.multiplyColours(blockColour, 0xff000000 | renderColour);
			}
		} catch (RuntimeException e) {
			// do nothing
		}
		break;
	case LEAVES:
		// leaves look weird on the map if they are not opaque.
		// they also look too dark if the render colour is applied.
		blockColour |= 0xff000000;
		break;
	default:
		break;
	}
	return blockColour;
}