當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityVillager.hasCustomName方法代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:34,代碼來源:EntityZombie.java

示例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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:34,代碼來源:EntityZombie.java


注:本文中的net.minecraft.entity.passive.EntityVillager.hasCustomName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。