本文整理匯總了Java中net.minecraft.entity.passive.EntityVillager.hasCustomName方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityVillager.hasCustomName方法的具體用法?Java EntityVillager.hasCustomName怎麽用?Java EntityVillager.hasCustomName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.passive.EntityVillager
的用法示例。
在下文中一共展示了EntityVillager.hasCustomName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onKillEntity
import net.minecraft.entity.passive.EntityVillager; //導入方法依賴的package包/類
/**
* This method gets called when the entity kills another one.
*/
public void onKillEntity(EntityLivingBase entityLivingIn)
{
super.onKillEntity(entityLivingIn);
if ((this.world.getDifficulty() == EnumDifficulty.NORMAL || this.world.getDifficulty() == EnumDifficulty.HARD) && entityLivingIn instanceof EntityVillager)
{
if (this.world.getDifficulty() != EnumDifficulty.HARD && this.rand.nextBoolean())
{
return;
}
EntityVillager entityvillager = (EntityVillager)entityLivingIn;
EntityZombieVillager entityzombievillager = new EntityZombieVillager(this.world);
entityzombievillager.copyLocationAndAnglesFrom(entityvillager);
this.world.removeEntity(entityvillager);
entityzombievillager.onInitialSpawn(this.world.getDifficultyForLocation(new BlockPos(entityzombievillager)), new EntityZombie.GroupData(false));
entityzombievillager.func_190733_a(entityvillager.getProfession());
entityzombievillager.setChild(entityvillager.isChild());
entityzombievillager.setNoAI(entityvillager.isAIDisabled());
if (entityvillager.hasCustomName())
{
entityzombievillager.setCustomNameTag(entityvillager.getCustomNameTag());
entityzombievillager.setAlwaysRenderNameTag(entityvillager.getAlwaysRenderNameTag());
}
this.world.spawnEntityInWorld(entityzombievillager);
this.world.playEvent((EntityPlayer)null, 1026, new BlockPos(this), 0);
}
}
示例2: onKillEntity
import net.minecraft.entity.passive.EntityVillager; //導入方法依賴的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;
}
EntityVillager entityvillager = (EntityVillager)entityLivingIn;
EntityZombie entityzombie = new EntityZombie(this.worldObj);
entityzombie.copyLocationAndAnglesFrom(entityLivingIn);
this.worldObj.removeEntity(entityLivingIn);
entityzombie.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityzombie)), new EntityZombie.GroupData(false, true));
entityzombie.setVillagerType(entityvillager.getProfessionForge());
entityzombie.setChild(entityLivingIn.isChild());
entityzombie.setNoAI(entityvillager.isAIDisabled());
if (entityvillager.hasCustomName())
{
entityzombie.setCustomNameTag(entityvillager.getCustomNameTag());
entityzombie.setAlwaysRenderNameTag(entityvillager.getAlwaysRenderNameTag());
}
this.worldObj.spawnEntityInWorld(entityzombie);
this.worldObj.playEvent((EntityPlayer)null, 1026, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
}