28 lines
852 B
Java
28 lines
852 B
Java
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 bek, final Player ayg, final LivingEntity akw, final InteractionHand ajh) {
|
|
if (bek.hasCustomHoverName() && !(akw instanceof Player)) {
|
|
if (akw.isAlive()) {
|
|
akw.setCustomName(bek.getHoverName());
|
|
if (akw instanceof Mob) {
|
|
((Mob)akw).setPersistenceRequired();
|
|
}
|
|
bek.shrink(1);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|