package common.item;

import java.util.function.Function;

import common.block.Block;
import common.block.BlockDoublePlant;
import common.block.BlockDoublePlant.EnumPlantType;
import common.color.Colorizer;
import common.model.Model;
import common.model.ModelProvider;

public class ItemDoublePlant extends ItemMultiTexture
{
    public ItemDoublePlant(Block block, Block block2, Function<ItemStack, String> nameFunction)
    {
        super(block, block2, true, nameFunction);
    }

    public int getColorFromItemStack(ItemStack stack, int renderPass)
    {
        BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = BlockDoublePlant.EnumPlantType.byMetadata(stack.getMetadata());
        return blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN ? super.getColorFromItemStack(stack, renderPass) : Colorizer.getGrassColor(0.5D, 1.0D);
    }

    public Model getModel(ModelProvider provider, String name, int meta) {
    	return provider.getModel(this.getTransform(), "blocks/" + (
    			BlockDoublePlant.EnumPlantType.byMetadata(meta) == EnumPlantType.SUNFLOWER ? "sunflower_front" : 
    			BlockDoublePlant.EnumPlantType.byMetadata(meta).getName() + "_top"));
    }
}
