package common.item;

import common.block.Block;
import common.color.DyeColor;
import common.model.Model;
import common.model.ModelProvider;

public class ItemCloth extends ItemBlock
{
	private final Integer display;
	
    public ItemCloth(Block block, Integer display, String flatTexture)
    {
        super(block, flatTexture);
        this.setMaxDamage(0);
        this.setHasSubtypes(true);
        this.display = display;
    }
    
    public ItemCloth(Block block, Integer display)
    {
        this(block, display, null);
    }

    /**
     * Converts the given ItemStack damage value into a metadata value to be placed in the world when this Item is
     * placed as a Block (mostly used with ItemBlocks).
     */
    public int getMetadata(int damage)
    {
        return damage;
    }

    /**
     * Returns the unlocalized name of this item. This version accepts an ItemStack so different stacks can have
     * different names based on their damage or NBT.
     */
    public String getDisplay(ItemStack stack)
    {
        return DyeColor.byMetadata(stack.getMetadata()).getSubject(this.display) + " " + super.getDisplay(stack);
    }

    public Model getModel(ModelProvider provider, String name, int meta) {
    	return this.flatTexture != null ? provider.getModel(this.getTransform(), "blocks/" + DyeColor.byMetadata(meta).getName() + "_" + 
    			this.flatTexture) : super.getModel(provider, name, meta);
    }
}
