Search in sources :

Example 6 with IItemColor

use of net.minecraft.client.renderer.color.IItemColor in project Bewitchment by Um-Mitternacht.

the class ClientProxy method init.

@Override
public void init(FMLInitializationEvent event) {
    Keybinds.registerKeys();
    BlockColors blocks = Minecraft.getMinecraft().getBlockColors();
    // Block Colors
    blocks.registerBlockColorHandler(new BlockCandleColorHandler(), ModBlocks.candle_medium, ModBlocks.candle_small, ModBlocks.candle_medium_lit, ModBlocks.candle_small_lit);
    blocks.registerBlockColorHandler(new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
            EnumGlyphType type = state.getValue(BlockCircleGlyph.TYPE);
            switch(type) {
                case ENDER:
                    return 0x770077;
                case GOLDEN:
                    return 0xe3dc3c;
                case NETHER:
                    return 0xbb0000;
                default:
                case NORMAL:
                    return 0xFFFFFF;
                case ANY:
                    // A green one should never happen!
                    return 0x00FF00;
            }
        }
    }, ModBlocks.ritual_glyphs);
    blocks.registerBlockColorHandler(new IBlockColor() {

        @Override
        public int colorMultiplier(IBlockState state, IBlockAccess worldIn, BlockPos pos, int tintIndex) {
            if (tintIndex == 1) {
                return Color.HSBtoRGB((pos.getX() + pos.getY() + pos.getZ()) % 50 / 50f, 0.4f, 1f);
            }
            return -1;
        }
    }, ModBlocks.crystal_ball);
    ItemColors items = Minecraft.getMinecraft().getItemColors();
    // Item Colors
    items.registerItemColorHandler(new ItemCandleColorHandler(), 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);
    items.registerItemColorHandler(new IItemColor() {

        @Override
        public int colorMultiplier(ItemStack stack, int tintIndex) {
            if (tintIndex == 0) {
                ISpell s = ItemSpellPage.getSpellFromItemStack(stack);
                if (s != null)
                    return s.getColor();
            }
            return -1;
        }
    }, ModItems.spell_page);
    NetworkRegistry.INSTANCE.registerGuiHandler(Bewitchment.instance, new GuiHandler());
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ISpell(com.bewitchment.api.spell.ISpell) IBlockAccess(net.minecraft.world.IBlockAccess) GuiHandler(com.bewitchment.common.core.net.GuiHandler) BlockColors(net.minecraft.client.renderer.color.BlockColors) IItemColor(net.minecraft.client.renderer.color.IItemColor) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ItemColors(net.minecraft.client.renderer.color.ItemColors) EnumGlyphType(com.bewitchment.api.ritual.EnumGlyphType) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 7 with IItemColor

use of net.minecraft.client.renderer.color.IItemColor in project EnderIO by SleepyTrousers.

the class PaintTintHandler method colorMultiplier.

@Override
public int colorMultiplier(@Nonnull ItemStack stack, int tintIndex) {
    if (Prep.isInvalid(stack)) {
        return -1;
    }
    Item item = stack.getItem();
    Block block = Block.getBlockFromItem(item);
    if (block instanceof IPaintable) {
        IBlockState paintSource = ((IPaintable) block).getPaintSource(block, stack);
        if (paintSource != null) {
            final ItemStack paintStack = new ItemStack(paintSource.getBlock(), 1, paintSource.getBlock().getMetaFromState(paintSource));
            if (paintStack.getItem() != item) {
                return Minecraft.getMinecraft().getItemColors().colorMultiplier(paintStack, tintIndex);
            }
        }
    }
    if (item instanceof IItemColor) {
        return ((IItemColor) item).colorMultiplier(stack, tintIndex);
    }
    if (item instanceof ITintedItem) {
        return ((ITintedItem) item).getItemTint(stack, tintIndex);
    }
    if (block instanceof IItemColor) {
        return ((IItemColor) block).colorMultiplier(stack, tintIndex);
    }
    if (block instanceof ITintedItem) {
        return ((ITintedItem) block).getItemTint(stack, tintIndex);
    }
    return -1;
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ITintedItem(crazypants.enderio.base.render.ITintedItem) IBlockState(net.minecraft.block.state.IBlockState) ITintedItem(crazypants.enderio.base.render.ITintedItem) IPaintable(crazypants.enderio.base.paint.IPaintable) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 8 with IItemColor

use of net.minecraft.client.renderer.color.IItemColor in project pnc-repressurized by TeamPneumatic.

the class ItemColorHandler method registerColorHandlers.

public static void registerColorHandlers() {
    final IItemColor ammoColor = (stack, tintIndex) -> {
        switch(tintIndex) {
            case 1:
                return getAmmoColor(stack);
            default:
                return Color.WHITE.getRGB();
        }
    };
    final IItemColor plasticColor = (stack, tintIndex) -> {
        int plasticColour = ItemPlastic.getColour(stack);
        return plasticColour >= 0 ? plasticColour : 0xffffff;
    };
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(ammoColor, Itemss.GUN_AMMO);
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(plasticColor, Itemss.PLASTIC);
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) java.awt(java.awt) ItemStack(net.minecraft.item.ItemStack) IItemColor(net.minecraft.client.renderer.color.IItemColor) Minecraft(net.minecraft.client.Minecraft) Nonnull(javax.annotation.Nonnull)

Aggregations

IItemColor (net.minecraft.client.renderer.color.IItemColor)8 ItemStack (net.minecraft.item.ItemStack)7 IBlockState (net.minecraft.block.state.IBlockState)4 Item (net.minecraft.item.Item)4 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)3 ItemColors (net.minecraft.client.renderer.color.ItemColors)3 IPaintable (crazypants.enderio.base.paint.IPaintable)2 ITintedBlock (crazypants.enderio.base.render.ITintedBlock)2 ITintedItem (crazypants.enderio.base.render.ITintedItem)2 Block (net.minecraft.block.Block)2 Minecraft (net.minecraft.client.Minecraft)2 BlockPos (net.minecraft.util.math.BlockPos)2 IBlockAccess (net.minecraft.world.IBlockAccess)2 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)2 EnumGlyphType (com.bewitchment.api.ritual.EnumGlyphType)1 ISpell (com.bewitchment.api.spell.ISpell)1 GuiHandler (com.bewitchment.common.core.net.GuiHandler)1 NNList (com.enderio.core.common.util.NNList)1 RenderGate (com.mraof.minestuck.client.renderer.tileentity.RenderGate)1 RenderSkaiaPortal (com.mraof.minestuck.client.renderer.tileentity.RenderSkaiaPortal)1