Search in sources :

Example 1 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project Witchworks by Um-Mitternacht.

the class ClientProxy method init.

@Override
public void init(FMLInitializationEvent event) {
    BlockColors blocks = Minecraft.getMinecraft().getBlockColors();
    //Block Colors
    blocks.registerBlockColorHandler(new BlockCandleColorHandler(), ModBlocks.CANDLE_LARGE, ModBlocks.CANDLE_MEDIUM, ModBlocks.CANDLE_SMALL);
    ItemColors items = Minecraft.getMinecraft().getItemColors();
    //Item Colors
    items.registerItemColorHandler(new ItemCandleColorHandler(), Item.getItemFromBlock(ModBlocks.CANDLE_LARGE), Item.getItemFromBlock(ModBlocks.CANDLE_MEDIUM), Item.getItemFromBlock(ModBlocks.CANDLE_SMALL));
    items.registerItemColorHandler(new BrewItemColorHandler(), ModItems.BREW_PHIAL_DRINK, ModItems.BREW_PHIAL_SPLASH, ModItems.BREW_PHIAL_LINGER);
    NetworkRegistry.INSTANCE.registerGuiHandler(WitchWorks.instance, new GuiHandler());
}
Also used : ItemColors(net.minecraft.client.renderer.color.ItemColors) ItemCandleColorHandler(com.witchworks.client.handler.ItemCandleColorHandler) BrewItemColorHandler(com.witchworks.client.handler.BrewItemColorHandler) GuiHandler(com.witchworks.common.core.net.GuiHandler) BlockCandleColorHandler(com.witchworks.client.handler.BlockCandleColorHandler) BlockColors(net.minecraft.client.renderer.color.BlockColors)

Example 2 with BlockColors

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

the class BlockGreenhouse method colorMultiplier.

@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("deprecation")
public int colorMultiplier(IBlockState blockState, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
    if (pos == null || world == null) {
        return 16777215;
    }
    ItemStack camouflageStack = getCamouflageBlock(world, pos);
    if (tintIndex == ModelCamouflaged.OVERLAY_COLOR_INDEX + 1) {
        BlockGreenhouseType type = getGreenhouseType(blockState);
        if (type == BlockGreenhouseType.SCREEN) {
            IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, pos, IGreenhouseComponent.class);
            if (controller == null || !controller.isAssembled()) {
                return 16777215;
            }
            IClimateContainer container = controller.getClimateContainer();
            IClimateState state = container.getState();
            return ClimateUtil.getColor(EnumTemperature.getFromValue(state.getTemperature()));
        } else if (type == BlockGreenhouseType.BORDER_CENTER) {
            boolean isClosed = true;
            IGreenhouseControllerInternal controller = MultiblockUtil.getController(world, pos, IGreenhouseComponent.class);
            if (controller == null || !controller.isAssembled()) {
                isClosed = false;
            } else {
                IGreenhouseProvider manager = controller.getProvider();
                isClosed = manager.isClosed();
            }
            return isClosed ? 1356406 : 12197655;
        }
    } else 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, world, pos, tintIndex);
            if (color != -1) {
                return color;
            }
        }
    }
    return 16777215;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IClimateContainer(forestry.greenhouse.api.climate.IClimateContainer) Block(net.minecraft.block.Block) IColoredBlock(forestry.core.blocks.IColoredBlock) IGreenhouseControllerInternal(forestry.greenhouse.multiblock.IGreenhouseControllerInternal) IClimateState(forestry.api.climate.IClimateState) IGreenhouseProvider(forestry.greenhouse.api.greenhouse.IGreenhouseProvider) ItemStack(net.minecraft.item.ItemStack) BlockColors(net.minecraft.client.renderer.color.BlockColors) IGreenhouseComponent(forestry.api.multiblock.IGreenhouseComponent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with BlockColors

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

the class Cavern method registerItemColors.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void registerItemColors(ColorHandlerEvent.Item event) {
    ItemColors itemColors = event.getItemColors();
    BlockColors blockColors = event.getBlockColors();
    CaveBlocks.registerItemBlockColors(blockColors, itemColors);
}
Also used : ItemColors(net.minecraft.client.renderer.color.ItemColors) BlockColors(net.minecraft.client.renderer.color.BlockColors) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project Binnie 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 5 with BlockColors

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

the class ClientProxyMP method init.

@Override
public void init(FMLInitializationEvent event) {
    BlockColors color = Minecraft.getMinecraft().getBlockColors();
    ItemModelRenderer.init();
    TileEntityRenderer.init();
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> world != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(world, pos) : ColorUtils.rgbToDecimal(124, 173, 38), MPBlocks.FRONOS_GRASS_BLOCK);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> ColorUtils.rgbToDecimal(120, 85, 190), MPBlocks.INFECTED_PURLONITE_CRYSTAL);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> ColorUtils.rgbToDecimal(50, 101, 236), MPBlocks.MULTALIC_CRYSTAL);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> ColorUtils.rgbToDecimal(50, 101, 236), MPBlocks.MULTALIC_CRYSTAL_BLOCK);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> ColorUtils.rgbToDecimal(143, 55, 33), MPBlocks.INFECTED_MELON_STEM);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> world != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(world, pos) : ColorUtils.rgbToDecimal(124, 173, 38), MPBlocks.FRONOS_GRASS);
    ClientRegistryUtils.registerBlockColor((state, world, pos, tint) -> world != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(world, pos) : ColorUtils.rgbToDecimal(124, 173, 38), MPBlocks.FRONOS_TALL_GRASS);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> color.colorMultiplier(((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), MPBlocks.FRONOS_GRASS_BLOCK);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> ColorUtils.rgbToDecimal(50, 101, 236), MPBlocks.MULTALIC_CRYSTAL_BLOCK);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> tintIndex == 1 ? ItemCapsule.CapsuleType.INFECTED_SPORE.getColor() : -1, MPItems.INFECTED_SPORE_PROTECTION_CAPSULE);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> tintIndex == 1 ? ItemCapsule.CapsuleType.DARK_ENERGY.getColor() : -1, MPItems.DARK_ENERGY_PROTECTION_CAPSULE);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> color.colorMultiplier(((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), MPBlocks.FRONOS_GRASS);
    ClientRegistryUtils.registerItemColor((itemStack, tintIndex) -> color.colorMultiplier(((ItemBlock) itemStack.getItem()).getBlock().getDefaultState(), null, null, tintIndex), MPBlocks.FRONOS_TALL_GRASS);
}
Also used : BlockColors(net.minecraft.client.renderer.color.BlockColors)

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