Search in sources :

Example 11 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project Cavern2 by kegare.

the class Cavern method registerBlockColors.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void registerBlockColors(ColorHandlerEvent.Block event) {
    BlockColors colors = event.getBlockColors();
    CaveBlocks.registerBlockColors(colors);
}
Also used : BlockColors(net.minecraft.client.renderer.color.BlockColors) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project HorsePower by GoryMoon.

the class ColorGetter method getBlockColors.

private static List<Color> getBlockColors(ItemStack itemStack, Block block, int colorCount) {
    final int meta = itemStack.getMetadata();
    IBlockState blockState;
    try {
        blockState = block.getStateFromMeta(meta);
    } catch (RuntimeException ignored) {
        blockState = block.getDefaultState();
    } catch (LinkageError ignored) {
        blockState = block.getDefaultState();
    }
    final BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
    final int renderColor = blockColors.colorMultiplier(blockState, null, null, 0);
    final TextureAtlasSprite textureAtlasSprite = getTextureAtlasSprite(blockState);
    if (textureAtlasSprite == null) {
        return Collections.emptyList();
    }
    return getColors(textureAtlasSprite, renderColor, colorCount);
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) BlockColors(net.minecraft.client.renderer.color.BlockColors)

Example 13 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project ForestryMC by ForestryMC.

the class ModelManager method registerItemAndBlockColors.

@SideOnly(Side.CLIENT)
public void registerItemAndBlockColors() {
    Minecraft minecraft = Minecraft.getMinecraft();
    BlockColors blockColors = minecraft.getBlockColors();
    for (IColoredBlock blockColor : blockColorList) {
        if (blockColor instanceof Block) {
            blockColors.registerBlockColorHandler(ColoredBlockBlockColor.INSTANCE, (Block) blockColor);
        }
    }
    ItemColors itemColors = minecraft.getItemColors();
    for (IColoredItem itemColor : itemColorList) {
        if (itemColor instanceof Item) {
            itemColors.registerItemColorHandler(ColoredItemItemColor.INSTANCE, (Item) itemColor);
        }
    }
}
Also used : Item(net.minecraft.item.Item) IColoredItem(forestry.core.items.IColoredItem) IColoredBlock(forestry.core.blocks.IColoredBlock) ItemColors(net.minecraft.client.renderer.color.ItemColors) IColoredBlock(forestry.core.blocks.IColoredBlock) Block(net.minecraft.block.Block) IColoredItem(forestry.core.items.IColoredItem) Minecraft(net.minecraft.client.Minecraft) BlockColors(net.minecraft.client.renderer.color.BlockColors) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 14 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project ForestryMC by ForestryMC.

the class BlockClimatiser method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation")
public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex) {
    if (pos == null || worldIn == null) {
        return 0xffffff;
    }
    ItemStack camouflageStack = getCamouflageBlock(worldIn, pos);
    if (tintIndex < ModelCamouflaged.OVERLAY_COLOR_INDEX && !camouflageStack.isEmpty()) {
        Block block = Block.getBlockFromItem(camouflageStack.getItem());
        if (block != Blocks.AIR) {
            IBlockState camouflageState = block.getStateFromMeta(camouflageStack.getItemDamage());
            BlockColors blockColors = Minecraft.getMinecraft().getBlockColors();
            int color = blockColors.colorMultiplier(camouflageState, worldIn, pos, tintIndex);
            if (color != -1) {
                return color;
            }
        }
    }
    return 0xffffff;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) IColoredBlock(forestry.core.blocks.IColoredBlock) ItemStack(net.minecraft.item.ItemStack) BlockColors(net.minecraft.client.renderer.color.BlockColors) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project Geolosys by oitsjustjose.

the class BlockColorInit method registerBlockColors.

@SubscribeEvent
public static void registerBlockColors(ColorHandlerEvent.Block evt) {
    BlockColors blockColors = evt.getBlockColors();
    blockColors.register((unknown, lightReader, pos, unknown2) -> lightReader != null && pos != null ? BiomeColors.getGrassColor(lightReader, pos) : GrassColors.get(0.5D, 1.0D), ModBlocks.getInstance().peat);
    blockColors.register((unknown, lightReader, pos, unknown2) -> lightReader != null && pos != null ? BiomeColors.getGrassColor(lightReader, pos) : GrassColors.get(0.5D, 1.0D), ModBlocks.getInstance().rhododendron);
}
Also used : BlockColors(net.minecraft.client.renderer.color.BlockColors) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

BlockColors (net.minecraft.client.renderer.color.BlockColors)17 ItemColors (net.minecraft.client.renderer.color.ItemColors)7 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 Block (net.minecraft.block.Block)5 IBlockState (net.minecraft.block.state.IBlockState)5 IColoredBlock (forestry.core.blocks.IColoredBlock)4 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 ItemStack (net.minecraft.item.ItemStack)3 IColoredItem (forestry.core.items.IColoredItem)2 Minecraft (net.minecraft.client.Minecraft)2 IItemColor (net.minecraft.client.renderer.color.IItemColor)2 Item (net.minecraft.item.Item)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 GDBiomeBase (androsa.gaiadimension.biomes.GDBiomeBase)1 IFacadePhasedState (buildcraft.api.facades.IFacadePhasedState)1 EnumGlyphType (com.bewitchment.api.ritual.EnumGlyphType)1 ISpell (com.bewitchment.api.spell.ISpell)1 GuiHandler (com.bewitchment.common.core.net.GuiHandler)1 ModBlocks (com.oitsjustjose.geolosys.common.blocks.ModBlocks)1 BlockCandleColorHandler (com.witchworks.client.handler.BlockCandleColorHandler)1