Search in sources :

Example 16 with BlockColors

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

the class BlockColorInit method registerItemColors.

@SubscribeEvent
public static void registerItemColors(ColorHandlerEvent.Item evt) {
    final BlockColors blockColors = evt.getBlockColors();
    final ItemColors itemColors = evt.getItemColors();
    // Use the Block's colour handler for an ItemBlock
    IItemColor itemBlockColourHandler = (stack, tintIndex) -> {
        BlockState state = ((BlockItem) stack.getItem()).getBlock().getDefaultState();
        return blockColors.getColor(state, null, null, tintIndex);
    };
    if (itemBlockColourHandler != null) {
        itemColors.register(itemBlockColourHandler, ModBlocks.getInstance().peat);
        itemColors.register(itemBlockColourHandler, ModBlocks.getInstance().rhododendron);
    }
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) BlockColors(net.minecraft.client.renderer.color.BlockColors) IItemColor(net.minecraft.client.renderer.color.IItemColor) BiomeColors(net.minecraft.world.biome.BiomeColors) ItemColors(net.minecraft.client.renderer.color.ItemColors) BlockItem(net.minecraft.item.BlockItem) GrassColors(net.minecraft.world.GrassColors) Mod(net.minecraftforge.fml.common.Mod) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent) BlockState(net.minecraft.block.BlockState) ColorHandlerEvent(net.minecraftforge.client.event.ColorHandlerEvent) ModBlocks(com.oitsjustjose.geolosys.common.blocks.ModBlocks) Dist(net.minecraftforge.api.distmarker.Dist) BlockState(net.minecraft.block.BlockState) ItemColors(net.minecraft.client.renderer.color.ItemColors) BlockColors(net.minecraft.client.renderer.color.BlockColors) BlockItem(net.minecraft.item.BlockItem) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 17 with BlockColors

use of net.minecraft.client.renderer.color.BlockColors in project Gaia-Dimension by Andromander.

the class ClientEvents method registerBlockColors.

@SubscribeEvent
public static void registerBlockColors(ColorHandlerEvent.Block e) {
    BlockColors blocks = e.getBlockColors();
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null && worldIn.getBiome(pos) instanceof GDBiomeBase ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : 0xF2A3B4, GDBlocks.glitter_grass, GDBlocks.crystal_growth);
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null && worldIn.getBiome(pos) instanceof GDBiomeBase ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : 0x606060, GDBlocks.murky_grass);
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> worldIn != null && pos != null && worldIn.getBiome(pos) instanceof GDBiomeBase ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : 0xA0A0A0, GDBlocks.soft_grass);
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> {
        if (worldIn != null && pos != null) {
            int red = (int) ((MathHelper.cos((float) Math.toRadians(pos.getX() * 2)) + 1F) / 2F * 0xFF);
            int green = (int) ((MathHelper.cos((float) Math.toRadians(pos.getY() * 2)) + 1F) / 3F * 0xFF);
            int blue = (int) ((MathHelper.cos((float) Math.toRadians(pos.getZ() * 2)) + 1F) / 2F * 0xFF);
            red = MathHelper.clamp(red, 0, 170);
            green = MathHelper.clamp(green, 0, 160);
            blue = MathHelper.clamp(blue, 0, 180);
            return (blue << 16) | (red << 8) | green;
        } else {
            return 0x808080;
        }
    }, GDBlocks.liquid_bismuth_block);
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> {
        if (worldIn != null && pos != null) {
            int red = (int) ((MathHelper.cos((float) Math.toRadians((pos.getX() + 100) * 8)) + 1F) / 2F * 0xFF);
            int green = (int) ((MathHelper.cos((float) Math.toRadians((pos.getY() + 100) * 32)) + 1F) / 2F * 0xFF);
            int blue = (int) ((MathHelper.cos((float) Math.toRadians((pos.getZ() + 100) * 8)) + 1F) / 2F * 0xFF);
            red = MathHelper.clamp(red, 150, 256);
            green = MathHelper.clamp(green, 100, 220);
            blue = MathHelper.clamp(blue, 150, 256);
            return (red << 16) | (green << 8) | blue;
        } else {
            return 0xFFFFFF;
        }
    }, GDBlocks.liquid_aura_block, GDBlocks.aura_leaves);
    blocks.registerBlockColorHandler((state, worldIn, pos, tintIndex) -> {
        int hex;
        if (worldIn != null && pos != null) {
            int location = (Math.abs(pos.getX() % 5)) + (Math.abs(pos.getZ() % 5));
            switch(location) {
                case 0:
                    hex = 0xEA500D;
                    break;
                case 1:
                    hex = 0xFFC24C;
                    break;
                case 2:
                    hex = 0xC1ED26;
                    break;
                case 3:
                    hex = 0x67FFB9;
                    break;
                case 4:
                    hex = 0x265AEf;
                    break;
                case 5:
                    hex = 0x5C0AD7;
                    break;
                case 6:
                    hex = 0x5D3883;
                    break;
                case 7:
                    hex = 0xC330E8;
                    break;
                case 8:
                    hex = 0xFF6CAE;
                    break;
                default:
                    hex = 0x5D3883;
                    break;
            }
        } else {
            hex = 0x1109B7;
        }
        return hex;
    }, GDBlocks.aura_shoot);
}
Also used : GDBiomeBase(androsa.gaiadimension.biomes.GDBiomeBase) BlockColors(net.minecraft.client.renderer.color.BlockColors) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.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