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


Java EntityVillager類代碼示例

本文整理匯總了Java中net.minecraft.entity.passive.EntityVillager的典型用法代碼示例。如果您正苦於以下問題:Java EntityVillager類的具體用法?Java EntityVillager怎麽用?Java EntityVillager使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


EntityVillager類屬於net.minecraft.entity.passive包,在下文中一共展示了EntityVillager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEntityDeath

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
	// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
	if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
	{
		// iterate through the itemstacks in the villager's inventory
		InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
		for (int i = 0; i < inventory.getSizeInventory(); i++)
		{
			// remove the stack from the inventory and spawn it in the world
			ItemStack stack = inventory.getStackInSlot(i);
			if (stack != ItemStack.EMPTY)
			{
				event.getEntityLiving().entityDropItem(stack, 0.0F);
			}
		}
	}
}
 
開發者ID:crazysnailboy,項目名稱:VillagerInventory,代碼行數:20,代碼來源:VillagerInventoryMod.java

示例2: convertToVillager

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Convert this zombie into a villager.
 */
protected void convertToVillager()
{
    EntityVillager entityvillager = new EntityVillager(this.worldObj);
    entityvillager.copyLocationAndAnglesFrom(this);
    entityvillager.onInitialSpawn(this.worldObj.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
    entityvillager.setLookingForHome();

    if (this.isChild())
    {
        entityvillager.setGrowingAge(-24000);
    }

    this.worldObj.removeEntity(this);
    entityvillager.setNoAI(this.isAIDisabled());

    if (this.hasCustomName())
    {
        entityvillager.setCustomNameTag(this.getCustomNameTag());
        entityvillager.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag());
    }

    this.worldObj.spawnEntityInWorld(entityvillager);
    entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
    this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, new BlockPos((int)this.posX, (int)this.posY, (int)this.posZ), 0);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:29,代碼來源:EntityZombie.java

示例3: convertToVillager

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@Override
protected void convertToVillager() {
	EntityVillager villager = new EntityVillager(worldObj);
	villager.copyLocationAndAnglesFrom(this);
	villager.onSpawnWithEgg((IEntityLivingData) null);
	villager.setLookingForHome();
	villager.setProfession(getType());

	if (isChild())
		villager.setGrowingAge(-24000);

	worldObj.removeEntity(this);
	worldObj.spawnEntityInWorld(villager);
	villager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
	worldObj.playAuxSFXAtEntity(null, 1017, (int) posX, (int) posY, (int) posZ, 0);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:17,代碼來源:EntityZombieVillager.java

示例4: shouldExecute

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (!this.theGolem.worldObj.isDaytime())
    {
        return false;
    }
    else if (this.theGolem.getRNG().nextInt(8000) != 0)
    {
        return false;
    }
    else
    {
        this.theVillager = (EntityVillager)this.theGolem.worldObj.findNearestEntityWithinAABB(EntityVillager.class, this.theGolem.getEntityBoundingBox().expand(6.0D, 2.0D, 6.0D), this.theGolem);
        return this.theVillager != null;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:EntityAILookAtVillager.java

示例5: getEntityTexture

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
 */
protected ResourceLocation getEntityTexture(EntityVillager entity)
{
    switch (entity.getProfession())
    {
        case 0:
            return farmerVillagerTextures;

        case 1:
            return librarianVillagerTextures;

        case 2:
            return priestVillagerTextures;

        case 3:
            return smithVillagerTextures;

        case 4:
            return butcherVillagerTextures;

        default:
            return villagerTextures;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:RenderVillager.java

示例6: preRenderCallback

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
 * entityLiving, partialTickTime
 */
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime)
{
    float f = 0.9375F;

    if (entitylivingbaseIn.getGrowingAge() < 0)
    {
        f = (float)((double)f * 0.5D);
        this.shadowSize = 0.25F;
    }
    else
    {
        this.shadowSize = 0.5F;
    }

    GlStateManager.scale(f, f, f);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:RenderVillager.java

示例7: spawnVillagers

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
protected void spawnVillagers(World worldIn, StructureBoundingBox p_74893_2_, int p_74893_3_, int p_74893_4_, int p_74893_5_, int p_74893_6_)
{
    if (this.villagersSpawned < p_74893_6_)
    {
        for (int i = this.villagersSpawned; i < p_74893_6_; ++i)
        {
            int j = this.getXWithOffset(p_74893_3_ + i, p_74893_5_);
            int k = this.getYWithOffset(p_74893_4_);
            int l = this.getZWithOffset(p_74893_3_ + i, p_74893_5_);

            if (!p_74893_2_.isVecInside(new BlockPos(j, k, l)))
            {
                break;
            }

            ++this.villagersSpawned;
            EntityVillager entityvillager = new EntityVillager(worldIn);
            entityvillager.setLocationAndAngles((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F);
            entityvillager.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null);
            entityvillager.setProfession(this.func_180779_c(i, entityvillager.getProfession()));
            worldIn.spawnEntityInWorld(entityvillager);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:25,代碼來源:StructureVillagePieces.java

示例8: getEntityColor

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public Color getEntityColor() {
	if ((entity instanceof EntityAnimal)) {
		return Color.white;
	}
	if ((entity instanceof EntityMob)) {
		return Color.red;
	}
	if ((entity instanceof EntitySlime)) {
		return Color.green;
	}
	if ((entity instanceof EntityVillager)) {
		return new Color(245, 245, 220);
	}
	if ((entity instanceof EntityBat)) {
		return Color.BLACK;
	}
	if ((entity instanceof EntitySquid)) {
		return Color.PINK;
	}
	return Color.white;
}
 
開發者ID:Moudoux,項目名稱:EMC,代碼行數:22,代碼來源:IEntity.java

示例9: getEntityTexture

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
 */
protected ResourceLocation getEntityTexture(EntityVillager entity)
{
    switch (entity.getProfession())
    {
        case 0:
            return FARMER_VILLAGER_TEXTURES;

        case 1:
            return LIBRARIAN_VILLAGER_TEXTURES;

        case 2:
            return PRIEST_VILLAGER_TEXTURES;

        case 3:
            return SMITH_VILLAGER_TEXTURES;

        case 4:
            return BUTCHER_VILLAGER_TEXTURES;

        case 5:
        default:
            return VILLAGER_TEXTURES;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:28,代碼來源:RenderVillager.java

示例10: preRenderCallback

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Allows the render to do state modifications necessary before the model is rendered.
 */
protected void preRenderCallback(EntityVillager entitylivingbaseIn, float partialTickTime)
{
    float f = 0.9375F;

    if (entitylivingbaseIn.getGrowingAge() < 0)
    {
        f = (float)((double)f * 0.5D);
        this.shadowSize = 0.25F;
    }
    else
    {
        this.shadowSize = 0.5F;
    }

    GlStateManager.scale(f, f, f);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:20,代碼來源:RenderVillager.java

示例11: handleVillagers

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
private void handleVillagers(int x, int y, List<IWidget> locatedTextures) {
        locatedTextures.add(new LocatedEntity(EntityVillager.class, x + 70, y + 95, 2F));

        LocatedEntity locatedEntity = new LocatedEntity(EntityVillager.class, x + 215, y + 125, 2F);
        EntityVillager villager = (EntityVillager) locatedEntity.entity;
//        villager.setProfession(ConfigHandler.general.villagerMechanicID);
        locatedTextures.add(locatedEntity);
    }
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:9,代碼來源:IntegratorPressureChamber.java

示例12: entitySpawned

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
@SubscribeEvent
public static void entitySpawned(EntityJoinWorldEvent event){
	// This only runs server side
	if(event.getWorld().isRemote)return;
	if(EntityVillager.class.isInstance(event.getEntity())
			&& !event.getEntity().getEntityData().getBoolean(tagName)){
		if(ConfigHandler.LOGGING){
			LogManager.getLogger().log(Level.INFO, "A villager spawned at x" + event.getEntity().posX + "z" + event.getEntity().posZ + " and has been added to the data list.");
		}
		// set this to true to inform future calls of this code that this villager has been handled.
		event.getEntity().getEntityData().setBoolean(tagName, true);
		// have to use the MathHelper workaround because chunkX and chunkZ are 0 on spawn
		NBTDataHandler.incrementVillagersSpawnedForChunk(event.getWorld().provider.getDimension(), MathHelper.floor(event.getEntity().posX / 16.0D), MathHelper.floor(event.getEntity().posZ / 16.0D));
	}
}
 
開發者ID:Edicatad,項目名稱:EmergentVillages,代碼行數:16,代碼來源:SpawnHandler.java

示例13: isPassive

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
/**
 * Checks if the specified entity is a passive
 *
 * @param e The entity
 * @return Whether or not the entity is a passive
 */
public static boolean isPassive(Entity e) {
    if (e instanceof EntityPigZombie)
        return !isAngry((EntityPigZombie) e);

    if (e instanceof EntityIronGolem)
        return !isAngry((EntityIronGolem) e);

    if (e instanceof EntityPolarBear)
        return !isAngry((EntityPolarBear) e);

    if (e instanceof EntityAnimal)
        return true;

    if (e instanceof EntitySquid)
        return true;

    if (e instanceof EntityBat)
        return true;

    if (e instanceof EntityVillager)
        return true;

    if (e instanceof EntitySnowman)
        return true;

    return false;
}
 
開發者ID:ImpactDevelopment,項目名稱:ClientAPI,代碼行數:34,代碼來源:EntityFilters.java

示例14: replaceList

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public void replaceList(IMerchant merchant, MerchantRecipeList list)
{
    if(merchant instanceof EntityVillager)
    {
        replaceTradeList((EntityVillager) merchant,list);
    }
    else
    {
        merchant.setRecipes(list);
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:12,代碼來源:VillagerAntimonyHandler.java

示例15: replaceTradeList

import net.minecraft.entity.passive.EntityVillager; //導入依賴的package包/類
public static void replaceTradeList(EntityVillager villager, MerchantRecipeList newlist) {
    if (buyingList == null)
        buyingList = ReflectionHelper.findField(EntityVillager.class, "buyingList", "field_70963_i");

    if (villager != null) {
        try {
            buyingList.set(villager, newlist);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:DaedalusGame,項目名稱:Soot,代碼行數:13,代碼來源:VillagerAntimonyHandler.java


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