package net.minecraft.world.item;

import net.minecraft.world.entity.Mob;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;

public class NameTagItem extends Item {
    public NameTagItem(final Properties a) {
        super(a);
    }
    
    @Override
    public boolean interactEnemy(final ItemStack ben, final Player ayj, final LivingEntity akz, final InteractionHand ajk) {
        if (ben.hasCustomHoverName() && !(akz instanceof Player)) {
            if (akz.isAlive()) {
                akz.setCustomName(ben.getHoverName());
                if (akz instanceof Mob) {
                    ((Mob)akz).setPersistenceRequired();
                }
                ben.shrink(1);
            }
            return true;
        }
        return false;
    }
}
