package common.item.tool;

import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving;
import common.item.CheatTab;
import common.item.Item;
import common.item.ItemStack;

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

    /**
     * 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.size;
            return true;
        }
        else
        {
            return super.itemInteractionForEntity(stack, playerIn, target);
        }
    }
}
