本文整理汇总了Java中net.minecraft.entity.EntityLiving.hasCustomName方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLiving.hasCustomName方法的具体用法?Java EntityLiving.hasCustomName怎么用?Java EntityLiving.hasCustomName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLiving
的用法示例。
在下文中一共展示了EntityLiving.hasCustomName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKillEntity
import net.minecraft.entity.EntityLiving; //导入方法依赖的package包/类
/**
* This method gets called when the entity kills another one.
*/
public void onKillEntity(EntityLivingBase entityLivingIn)
{
super.onKillEntity(entityLivingIn);
if ((this.worldObj.getDifficulty() == EnumDifficulty.NORMAL || this.worldObj.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
{
if (this.worldObj.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
{
return;
}
EntityLiving entityliving = (EntityLiving)entityLivingIn;
EntityZombie entityzombie = new EntityZombie(this.worldObj);
entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
this.worldObj.removeEntity(entityLivingIn);
entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), (IEntityLivingData)null);
entityzombie.setVillager(true);
if (entityLivingIn.isChild())
{
entityzombie.setChild(true);
}
entityzombie.setNoAI(entityliving.isAIDisabled());
if (entityliving.hasCustomName())
{
entityzombie.setCustomNameTag(entityliving.getCustomNameTag());
entityzombie.setAlwaysRenderNameTag(entityliving.getAlwaysRenderNameTag());
}
this.worldObj.spawnEntityInWorld(entityzombie);
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1016, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
}