Search in sources :

Example 11 with ItemColors

use of net.minecraft.client.renderer.color.ItemColors 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 12 with ItemColors

use of net.minecraft.client.renderer.color.ItemColors 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 13 with ItemColors

use of net.minecraft.client.renderer.color.ItemColors in project NetherEx by LogicTechCorp.

the class NetherEx method onRegisterItemColor.

@OnlyIn(Dist.CLIENT)
private void onRegisterItemColor(ColorHandlerEvent.Item event) {
    ItemColors colors = event.getItemColors();
    NetherExItems.getItems().forEach(registryObject -> {
        registryObject.ifPresent(item -> {
            if (item instanceof ModSpawnEggItem) {
                colors.register((color, index) -> ((ModSpawnEggItem) item).getColor(index), item);
            }
        });
    });
}
Also used : ItemColors(net.minecraft.client.renderer.color.ItemColors) ModSpawnEggItem(logictechcorp.libraryex.item.ModSpawnEggItem) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Aggregations

ItemColors (net.minecraft.client.renderer.color.ItemColors)13 BlockColors (net.minecraft.client.renderer.color.BlockColors)7 IItemColor (net.minecraft.client.renderer.color.IItemColor)4 Item (net.minecraft.item.Item)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 IBlockState (net.minecraft.block.state.IBlockState)3 ItemStack (net.minecraft.item.ItemStack)3 IColoredBlock (forestry.core.blocks.IColoredBlock)2 IColoredItem (forestry.core.items.IColoredItem)2 Block (net.minecraft.block.Block)2 Minecraft (net.minecraft.client.Minecraft)2 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)2 BlockPos (net.minecraft.util.math.BlockPos)2 IBlockAccess (net.minecraft.world.IBlockAccess)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EnumGlyphType (com.bewitchment.api.ritual.EnumGlyphType)1 ISpell (com.bewitchment.api.spell.ISpell)1 GuiHandler (com.bewitchment.common.core.net.GuiHandler)1 ItemWorktableTool (com.codetaylor.mc.artisanworktables.modules.tools.item.ItemWorktableTool)1 ModBlocks (com.oitsjustjose.geolosys.common.blocks.ModBlocks)1