package common.item;

import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;

public class ItemNameTag extends Item
{
    public ItemNameTag()
    {
        this.setTab(CheatTab.tabTools);
    }

    /**
     * Returns true if the item can be used on the given entity, e.g. shears on sheep.
     */
    public boolean itemInteractionForEntity(ItemStack stack, EntityNPC playerIn, EntityLiving target)
    {
        if (!stack.hasDisplayName())
        {
            return false;
        }
        else if (target instanceof EntityLiving && !(target.isPlayer()))
        {
            EntityLiving entityliving = (EntityLiving)target;
            entityliving.setCustomNameTag(stack.getDisplayName());
//            entityliving.disableDespawn();
            --stack.stackSize;
            return true;
        }
        else
        {
            return super.itemInteractionForEntity(stack, playerIn, target);
        }
    }
}
