Search in sources :

Example 1 with ITintedBlock

use of crazypants.enderio.base.render.ITintedBlock in project EnderIO by SleepyTrousers.

the class PaintTintHandler method colorMultiplier.

@Override
public int colorMultiplier(@Nonnull IBlockState state, @Nullable IBlockAccess world, @Nullable BlockPos pos, int tintIndex) {
    if (world == null || pos == null) {
        return -1;
    }
    Block block = state.getBlock();
    IBlockState paintSource = null;
    if (block instanceof IPaintable) {
        paintSource = ((IPaintable) block).getPaintSource(state, world, pos);
        if (paintSource != null && paintSource.getBlock() != block) {
            block = paintSource.getBlock();
            state = paintSource;
        } else {
            paintSource = null;
        }
    }
    if (block instanceof ITintedBlock) {
        return ((ITintedBlock) block).getBlockTint(state, world, pos, tintIndex);
    }
    if (block instanceof IBlockColor) {
        return ((IBlockColor) block).colorMultiplier(state, world, pos, tintIndex);
    }
    if (paintSource != null) {
        return Minecraft.getMinecraft().getBlockColors().colorMultiplier(paintSource, world, pos, tintIndex);
    }
    return -1;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) IPaintable(crazypants.enderio.base.paint.IPaintable) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ITintedBlock(crazypants.enderio.base.render.ITintedBlock)

Example 2 with ITintedBlock

use of crazypants.enderio.base.render.ITintedBlock in project EnderIO by SleepyTrousers.

the class SmartModelAttacher method registerColoredBlocksAndItems.

@SideOnly(Side.CLIENT)
public static void registerColoredBlocksAndItems() {
    NNList<Block> blocklist = new NNList<Block>();
    NNList<Item> itemlist = new NNList<Item>();
    for (RegistrationHolder<?, ?> holder : blocks) {
        Block block = holder.block;
        Item item = Item.getItemFromBlock(block);
        if (block instanceof IPaintable || block instanceof ITintedBlock || block instanceof ITintedItem || item instanceof ITintedItem) {
            blocklist.add(block);
            if (item != Items.AIR) {
                itemlist.add(item);
            }
        } else {
            if (block instanceof IBlockColor) {
                Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler((IBlockColor) block, block);
            }
            if (item instanceof IItemColor) {
                Minecraft.getMinecraft().getItemColors().registerItemColorHandler((IItemColor) item, item);
            }
        }
    }
    PaintTintHandler handler = new PaintTintHandler();
    Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(handler, blocklist.toArray(new Block[0]));
    Minecraft.getMinecraft().getItemColors().registerItemColorHandler(handler, itemlist.toArray(new Item[0]));
}
Also used : IItemColor(net.minecraft.client.renderer.color.IItemColor) Item(net.minecraft.item.Item) ITintedItem(crazypants.enderio.base.render.ITintedItem) IBlockColor(net.minecraft.client.renderer.color.IBlockColor) ITintedItem(crazypants.enderio.base.render.ITintedItem) IPaintable(crazypants.enderio.base.paint.IPaintable) NNList(com.enderio.core.common.util.NNList) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) Block(net.minecraft.block.Block) ITintedBlock(crazypants.enderio.base.render.ITintedBlock) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IPaintable (crazypants.enderio.base.paint.IPaintable)2 ITintedBlock (crazypants.enderio.base.render.ITintedBlock)2 Block (net.minecraft.block.Block)2 IBlockColor (net.minecraft.client.renderer.color.IBlockColor)2 NNList (com.enderio.core.common.util.NNList)1 ITintedItem (crazypants.enderio.base.render.ITintedItem)1 IBlockState (net.minecraft.block.state.IBlockState)1 IItemColor (net.minecraft.client.renderer.color.IItemColor)1 Item (net.minecraft.item.Item)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1