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


Java EntityAnimal類代碼示例

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


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

示例1: affectChunk

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@Override
public void affectChunk(World world) {
	
	Chunk chunk = world.getChunkFromChunkCoords(chunkPos.x, chunkPos.z);
	
	for (int i = 0; i < chunk.getEntityLists().length; i++) {
		if (chunk.getEntityLists()[i] != null) {
			for (EntityAnimal e : chunk.getEntityLists()[i].getByClass(EntityAnimal.class)) {
				if (world.rand.nextInt(3) == 0) {
					e.addTag(TAG);
				}
			}
		}
	}

}
 
開發者ID:the-realest-stu,項目名稱:Etheric,代碼行數:17,代碼來源:InfertilityEvent.java

示例2: getNearbyMate

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
 * Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
 * valid mate found.
 */
private EntityAnimal getNearbyMate()
{
    float f = 8.0F;
    List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.theAnimal.getClass(), this.theAnimal.getEntityBoundingBox().expand((double)f, (double)f, (double)f));
    double d0 = Double.MAX_VALUE;
    EntityAnimal entityanimal = null;

    for (EntityAnimal entityanimal1 : list)
    {
        if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
        {
            entityanimal = entityanimal1;
            d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
        }
    }

    return entityanimal;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:EntityAIMate.java

示例3: checkValidity

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean checkValidity(final EntityLivingBase entity) {
    if (entity == this.mc.thePlayer) {
        return false;
    }
    if (!entity.isEntityAlive()) {
        return false;
    }
    if (this.mc.thePlayer.getDistanceToEntity(entity) > this.range) {
        return false;
    }
    if (!(entity instanceof EntityPlayer)) {
        return (this.monsters && entity instanceof EntityMob) || (this.animals && (entity instanceof EntityAnimal || entity instanceof EntitySquid)) || (this.bats && entity instanceof EntityBat);
    }
    if (this.players) {
        final EntityPlayer player = (EntityPlayer)entity;
        return (this.friend && FriendManager.isFriend(player.getName())) || (!FriendManager.isFriend(player.getName()) && (!this.noArmor || this.hasArmor(player)));
    }
    return false;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:20,代碼來源:Aura.java

示例4: interactEntityEvent

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
	if (stack == null)
		return;
	if (!(event.target instanceof EntityAnimal))
		return;

	EntityAnimal animal = (EntityAnimal) event.target;
	if (!animal.isChild()) {
		if (animal instanceof EntityPig) {
			if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
		} else if (animal instanceof EntityChicken)
			if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
	} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
		feedBaby(animal, event.entityPlayer, stack);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:20,代碼來源:ServerEventHandler.java

示例5: feedBaby

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private void feedBaby(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
	int currentAge = animal.getGrowingAge();
	int age = (int) (-currentAge * 0.1F);
	animal.setGrowingAge(currentAge + age);
	player.swingItem();

	Random itemRand = animal.worldObj.rand;
	for (int i = 0; i < 3; i++) {
		double d0 = itemRand.nextGaussian() * 0.02D;
		double d1 = itemRand.nextGaussian() * 0.02D;
		double d2 = itemRand.nextGaussian() * 0.02D;
		animal.worldObj.spawnParticle("happyVillager", animal.posX + itemRand.nextFloat() * 0.5, animal.posY + 0.5 + itemRand.nextFloat() * 0.5, animal.posZ + itemRand.nextFloat() * 0.5, d0, d1, d2);
	}

	if (!player.capabilities.isCreativeMode)
		if (--stack.stackSize <= 0)
			player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:19,代碼來源:ServerEventHandler.java

示例6: getEntityColor

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的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

示例7: getNearbyMate

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
 * Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
 * valid mate found.
 */
private EntityAnimal getNearbyMate()
{
    List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.field_190857_e, this.theAnimal.getEntityBoundingBox().expandXyz(8.0D));
    double d0 = Double.MAX_VALUE;
    EntityAnimal entityanimal = null;

    for (EntityAnimal entityanimal1 : list)
    {
        if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
        {
            entityanimal = entityanimal1;
            d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
        }
    }

    return entityanimal;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:22,代碼來源:EntityAIMate.java

示例8: BabyEntitySpawnEvent

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public BabyEntitySpawnEvent(EntityLiving parentA, EntityLiving parentB, @Nullable EntityAgeable proposedChild)
{
    //causedByPlayer calculated here to simplify the patch.
    EntityPlayer causedByPlayer = null;
    if (parentA instanceof EntityAnimal) {
        causedByPlayer = ((EntityAnimal)parentA).getPlayerInLove();
    }

    if (causedByPlayer == null && parentB instanceof EntityAnimal)
    {
        causedByPlayer = ((EntityAnimal)parentB).getPlayerInLove();
    }

    this.parentA = parentA;
    this.parentB = parentB;
    this.causedByPlayer = causedByPlayer;
    this.child = proposedChild;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:BabyEntitySpawnEvent.java

示例9: getNearbyMate

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
 * Loops through nearby animals and finds another animal of the same type that can be mated with. Returns the first
 * valid mate found.
 */
private EntityAnimal getNearbyMate()
{
    List<EntityAnimal> list = this.theWorld.<EntityAnimal>getEntitiesWithinAABB(this.theAnimal.getClass(), this.theAnimal.getEntityBoundingBox().expandXyz(8.0D));
    double d0 = Double.MAX_VALUE;
    EntityAnimal entityanimal = null;

    for (EntityAnimal entityanimal1 : list)
    {
        if (this.theAnimal.canMateWith(entityanimal1) && this.theAnimal.getDistanceSqToEntity(entityanimal1) < d0)
        {
            entityanimal = entityanimal1;
            d0 = this.theAnimal.getDistanceSqToEntity(entityanimal1);
        }
    }

    return entityanimal;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:EntityAIMate.java

示例10: onEntityCollidedWithBlock

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public void onEntityCollidedWithBlock(final World world, final int x, final int y, final int z, final Entity entity) {
    if (this.rand.nextInt(5) > 0) {
        return;
    }
    if (entity instanceof EntityAnimal) {
        final EntityAnimal animal = (EntityAnimal)entity;
        if (animal.getGrowingAge() < 0) {
            animal.addGrowth(this.rand.nextInt(40));
        }
        else if (animal.getGrowingAge() > 0) {
            int j = animal.getGrowingAge();
            j -= this.rand.nextInt(40);
            if (j < 0) {
                j = 0;
            }
            animal.setGrowingAge(j);
        }
        else if (!animal.isInLove()) {
            if (world.getEntitiesWithinAABB((Class)entity.getClass(), entity.boundingBox.expand(8.0, 8.0, 8.0)).size() > 32) {
                return;
            }
            animal.func_146082_f((EntityPlayer)null);
        }
    }
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:26,代碼來源:BlockPureLove.java

示例11: canMateWith

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
@Override
public boolean canMateWith(EntityAnimal par1EntityAnimal)
{
    if (par1EntityAnimal == this)
    {
        return false;
    }
    else if (!this.isTamed())
    {
        return false;
    }
    else if (!(par1EntityAnimal instanceof EntitySlimeling))
    {
        return false;
    }
    else
    {
        EntitySlimeling slimeling = (EntitySlimeling) par1EntityAnimal;
        return slimeling.isTamed() && !slimeling.isSitting() && this.isInLove() && slimeling.isInLove();
    }
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:22,代碼來源:EntitySlimeling.java

示例12: isEntityValidToAttack

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
public boolean isEntityValidToAttack(EntityMinionWarrior minion, EntityLivingBase entity)
{
	if(entity == minion || entity == minion.getRidingEntity() || !EntityAITarget.isSuitableTarget(minion, entity, false, false) || entity.getClass() == EntityCreeper.class) return false;
	
	if (entity instanceof EntityMob &&
			(getTargetBehavior() == EnumCombatBehaviors.TARGET_HOSTILE_MOBS || 
			getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
	{
		return true;
	}

	else if (entity instanceof EntityAnimal &&
			(getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_MOBS || 
			getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
	{
		return true;
	}

	else
	{
		return false;
	}
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:24,代碼來源:MinionAICombat.java

示例13: tryBreeding

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean tryBreeding(List<EntityPair> targets) {
	Entity animalA;
	Entity animalB;
	EntityPair pair;
	if (!targets.isEmpty()) {
		pair = targets.remove(0);
		animalA = pair.getEntityA(getWorld());
		animalB = pair.getEntityB(getWorld());
		if (!(animalA instanceof EntityAnimal)
				|| !(animalB instanceof EntityAnimal)) {
			return false;
		}
		if (!hasBreedingItem((EntityAnimal) animalA))
			return false;
		((EntityAnimal) animalA).setInLove(null);// setInLove(EntityPlayer
														// breeder)
		((EntityAnimal) animalB).setInLove(null);// setInLove(EntityPlayer
														// breeder)
		return true;
	}
	return false;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:23,代碼來源:WorksiteAnimalFarm.java

示例14: canMateWith

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal p_70878_1_)
{
    if (p_70878_1_ == this)
    {
        return false;
    }
    else if (!this.isTamed())
    {
        return false;
    }
    else if (!(p_70878_1_ instanceof EntityStymph))
    {
        return false;
    }
    else
    {
        EntityStymph entityocelot = (EntityStymph)p_70878_1_;
        return !entityocelot.isTamed() ? false : this.isInLove() && entityocelot.isInLove();
    }
}
 
開發者ID:GhostMonk3408,項目名稱:MidgarCrusade,代碼行數:24,代碼來源:EntityStymph.java

示例15: isValidTarget

import net.minecraft.entity.passive.EntityAnimal; //導入依賴的package包/類
private boolean isValidTarget(Entity e)
{
	if (e == null) return false;
	else if (e instanceof EntityPlayer)
	{
		EntityPlayer p = ((EntityPlayer) e);
		if (p.capabilities.isCreativeMode) return false;
		else
		{
			if (kPlayers) return true;
			else if (!kTeam) return false;
			RivalRebelsPlayer rrp = RivalRebels.round.rrplayerlist.getForName(((EntityPlayer) e).getCommandSenderName());
			if (rrp == null) return kTeam;
			if (rrp.rrteam == RivalRebelsTeam.NONE) return !p.getCommandSenderName().equals(username);
			if (rrp.rrteam != team) return kTeam;
			else return false;
		}
	}
	else return (kMobs && (e instanceof EntityRhodes || (e instanceof EntityMob && !(e instanceof EntityAnimal) && !(e instanceof EntityBat) && !(e instanceof EntityVillager) && !(e instanceof EntitySquid)) || e instanceof EntityGhast));
}
 
開發者ID:rodolphito,項目名稱:Rival-Rebels-Mod,代碼行數:21,代碼來源:TileEntityReciever.java


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