本文整理匯總了Java中net.minecraft.entity.EntityLiving.setCustomNameTag方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLiving.setCustomNameTag方法的具體用法?Java EntityLiving.setCustomNameTag怎麽用?Java EntityLiving.setCustomNameTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLiving
的用法示例。
在下文中一共展示了EntityLiving.setCustomNameTag方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: itemInteractionForEntity
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
* Returns true if the item can be used on the given entity, e.g. shears on sheep.
*/
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
if (!stack.hasDisplayName())
{
return false;
}
else if (target instanceof EntityLiving)
{
EntityLiving entityliving = (EntityLiving)target;
entityliving.setCustomNameTag(stack.getDisplayName());
entityliving.enablePersistence();
--stack.stackSize;
return true;
}
else
{
return super.itemInteractionForEntity(stack, playerIn, target);
}
}
示例2: itemInteractionForEntity
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
* Returns true if the item can be used on the given entity, e.g. shears on sheep.
*/
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand)
{
if (!stack.hasDisplayName())
{
return false;
}
else if (target instanceof EntityLiving)
{
EntityLiving entityliving = (EntityLiving)target;
entityliving.setCustomNameTag(stack.getDisplayName());
entityliving.enablePersistence();
--stack.stackSize;
return true;
}
else
{
return super.itemInteractionForEntity(stack, playerIn, target, hand);
}
}
示例3: decorate
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
* Convert the provided entity into the given nemesis
*
* @param entity the entity to be converted into a nemesis
* @param nemesis the nemesis to create
*/
public static void decorate(EntityLiving entity, NemesisEntry nemesis) {
entity.addTag(NemesisSystem.TAG_NEMESIS);
entity.getEntityData().setUniqueId(NemesisSystem.NBT_NEMESIS_ID, nemesis.getId());
entity.setCustomNameTag(nemesis.getNameAndTitle());
if (entity instanceof EntityZombie) {
((EntityZombie) entity).setChild(nemesis.isChild());
}
ItemStack helmet = nemesis.getArmorInventory().get(EntityEquipmentSlot.HEAD.getIndex());
entity.setItemStackToSlot(EntityEquipmentSlot.HEAD, helmet);
entity.setItemStackToSlot(EntityEquipmentSlot.CHEST, nemesis.getArmorInventory().get(EntityEquipmentSlot.CHEST.getIndex()));
entity.setItemStackToSlot(EntityEquipmentSlot.LEGS, nemesis.getArmorInventory().get(EntityEquipmentSlot.LEGS.getIndex()));
entity.setItemStackToSlot(EntityEquipmentSlot.FEET, nemesis.getArmorInventory().get(EntityEquipmentSlot.FEET.getIndex()));
entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, nemesis.getHandInventory().get(EntityEquipmentSlot.MAINHAND.getIndex()));
entity.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, nemesis.getHandInventory().get(EntityEquipmentSlot.OFFHAND.getIndex()));
for (IAttributeInstance attribute : entity.getAttributeMap().getAllAttributes()) {
if (attribute.getAttribute() == SharedMonsterAttributes.ATTACK_DAMAGE) {
attribute.setBaseValue(attribute.getAttributeValue() * (nemesis.getLevel() / 3));
}
if (attribute.getAttribute() == SharedMonsterAttributes.ATTACK_SPEED) {
attribute.setBaseValue(attribute.getAttributeValue() * (nemesis.getLevel() / 8));
}
if (attribute.getAttribute() == SharedMonsterAttributes.MAX_HEALTH) {
attribute.setBaseValue(attribute.getAttributeValue() * nemesis.getLevel());
entity.setHealth(entity.getMaxHealth());
}
}
}