Java Code Examples for net.minecraft.entity.passive.EntityAnimal

The following are top voted examples for showing how to use net.minecraft.entity.passive.EntityAnimal. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Etheric   File: InfertilityEvent.java   View source code 6 votes vote down vote up
@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);
				}
			}
		}
	}

}
 
Example 2
Project: DecompiledMinecraft   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Project: DecompiledMinecraft   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 4
Project: BaseClient   File: Aura.java   View source code 6 votes vote down vote up
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;
}
 
Example 5
Project: BaseClient   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Project: BaseClient   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
@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);
}
 
Example 8
Project: connor41-etfuturum2   File: ServerEventHandler.java   View source code 6 votes vote down vote up
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);
}
 
Example 9
Project: EMC   File: IEntity.java   View source code 6 votes vote down vote up
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;
}
 
Example 10
Project: Backmemed   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 11
Project: CustomWorldGen   File: BabyEntitySpawnEvent.java   View source code 6 votes vote down vote up
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;
}
 
Example 12
Project: CustomWorldGen   File: EntityAIMate.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Project: ExtraUtilities   File: BlockPureLove.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 14
Project: 4Space-5   File: EntitySlimeling.java   View source code 6 votes vote down vote up
@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();
    }
}
 
Example 15
Project: CrystalMod   File: MinionAICombat.java   View source code 6 votes vote down vote up
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;
	}
}
 
Example 16
Project: CrystalMod   File: WorksiteAnimalFarm.java   View source code 6 votes vote down vote up
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;
}
 
Example 17
Project: MidgarCrusade   File: EntityStymph.java   View source code 6 votes vote down vote up
/**
 * 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();
    }
}
 
Example 18
Project: Rival-Rebels-Mod   File: TileEntityReciever.java   View source code 6 votes vote down vote up
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));
}
 
Example 19
Project: ToroQuest   File: CivilizationHandlers.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void breed(BabyEntitySpawnEvent event) {
	if (!ToroQuestConfiguration.animalsAffectRep) {
		return;
	}
	if (!(event.getParentA() instanceof EntityAnimal)) {
		return;
	}

	if (!(event.getParentB() instanceof EntityAnimal)) {
		return;
	}

	EntityPlayer playerA = ((EntityAnimal) event.getParentA()).getLoveCause();
	EntityPlayer playerB = ((EntityAnimal) event.getParentB()).getLoveCause();

	if (playerA != null) {
		adjustPlayerRep(playerA, event.getParentA().chunkCoordX, event.getParentA().chunkCoordZ, 1);
	}

	if (playerB != null) {
		adjustPlayerRep(playerB, event.getParentB().chunkCoordX, event.getParentB().chunkCoordZ, 1);
	}
}
 
Example 20
Project: EssentialFeatures   File: EntityPanda.java   View source code 6 votes vote down vote up
/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal otherAnimal)
{
    if (otherAnimal == this)
    {
        return false;
    }
    else if (!this.isTamed())
    {
        return false;
    }
    else if (!(otherAnimal instanceof EntityPanda))
    {
        return false;
    }
    else
    {
        EntityPanda panda = (EntityPanda)otherAnimal;
        return !panda.isTamed() ? false : (panda.isSitting() ? false : this.isInLove() && panda.isInLove());
    }
}
 
Example 21
Project: Mekfarm   File: AnimalGymEntity.java   View source code 6 votes vote down vote up
private boolean packageCurrent() {
    EntityAnimal ea = this.getCurrent();
    if (ea == null) {
        return false;
    }

    ItemStack remaining = ItemHandlerHelper.insertItem(this.outStackHandler,
            AnimalFarmEntity.packageAnimal(null, ea),
            false);
    if (ItemStackUtil.isEmpty(remaining)) {
        this.currentAnimal = null;
        this.forceSync();
        this.markDirty();
        return true;
    }
    return false;
}
 
Example 22
Project: Mekfarm   File: AnimalWrapperFactory.java   View source code 6 votes vote down vote up
/**
 * @param entity
 * the entity to be wrapped
 * @return
 * return a nicely wrapped entity ready to be exploited in many many ways
 */
public static IAnimalWrapper getAnimalWrapper(EntityAnimal entity) {
    IAnimalWrapper wrapper = null;

    if (entity instanceof EntityHorse) {
        wrapper = new VanillaHorse((EntityHorse) entity);
    }

    if ((entity instanceof EntityCow) && entity.getClass().getName().equals("com.robrit.moofluids.common.entity.EntityFluidCow")) {
        wrapper = new MooFluidCow((EntityCow)entity);
    }

    if (wrapper == null) {
        wrapper = new VanillaGenericAnimal(entity);
    }
    return wrapper;
}
 
Example 23
Project: ToroHealth   File: AbstractHealthDisplay.java   View source code 6 votes vote down vote up
protected Relation determineRelation() {
	if (entity instanceof EntityMob) {
		return Relation.FOE;
	} else if (entity instanceof EntitySlime) {
		return Relation.FOE;
	} else if (entity instanceof EntityGhast) {
		return Relation.FOE;
	} else if (entity instanceof EntityAnimal) {
		return Relation.FRIEND;
	} else if (entity instanceof EntitySquid) {
		return Relation.FRIEND;
	} else if (entity instanceof EntityAmbientCreature) {
		return Relation.FRIEND;
	} else {
		return Relation.UNKNOWN;
	}
}
 
Example 24
Project: Tannery   File: EntityDropsHandler.java   View source code 6 votes vote down vote up
@SubscribeEvent
public void onLivingDrops(LivingDropsEvent event)
{
	Entity e = event.entity;
	List<EntityItem> drops = event.drops;
	// Remove all drops from cows, sheep and pigs, add carcass drop
	if (e instanceof EntityCow || e instanceof EntityPig || e instanceof EntitySheep)
	{
		EntityAnimal a = (EntityAnimal) e;
		Iterator<EntityItem> it = drops.iterator();
		while (it.hasNext())
		{
			EntityItem i = it.next();
			it.remove();
		}

		if (a.getGrowingAge() == 0)
		{
			if (a instanceof EntityCow) a.dropItem(TanneryItems.bloodyCowCarcass, 1);
			else if (a instanceof EntityPig) a.dropItem(TanneryItems.bloodyPigCarcass, 1);
			else if (a instanceof EntitySheep) a.dropItem(TanneryItems.bloodySheepCarcass, 1);
		}
	}
}
 
Example 25
Project: geomastery   File: EntityEvents.java   View source code 6 votes vote down vote up
/** Reduces animal spawns by half. */
@SubscribeEvent
public void checkSpawn(CheckSpawn event) {

    EntityLivingBase entity  = event.getEntityLiving();
    boolean canSpawn = true;
    
    if (entity instanceof EntityAnimal) {
        
        if (entity.world.rand.nextInt(2) == 0) {
            
            canSpawn = false;
        }
    }

    event.setResult(canSpawn ? Result.DEFAULT : Result.DENY);
}
 
Example 26
Project: MobHunter   File: EntityGiaprey.java   View source code 6 votes vote down vote up
public EntityGiaprey(World worldIn)
{
    super(worldIn, 1, 1);
    this.setSize(1.5F, 1.8125F);
    setBaseHealth(11);
    setBaseAttack(2);
    setBaseSpeed(0.3);
    setBaseKnockback(0.1);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask( 4, new EntityAIAttackMeleeAndSpit(this, 1.0D, 200, 16.0f,4.0f, true));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 27
Project: MobHunter   File: EntityGendrome.java   View source code 6 votes vote down vote up
public EntityGendrome(World worldIn) {
    super(worldIn, Config.scaleMin*0.75f, Config.scaleMax*0.75f);
    this.setSize(2.25F, 2.5F);
    setBaseHealth(300);
    setBaseAttack(2*1.5);
    setBaseSpeed(0.3*1.5);
    setBaseKnockback(0.5*1.5);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 28
Project: MobHunter   File: EntityJaggia.java   View source code 6 votes vote down vote up
public EntityJaggia(World worldIn)
{
    super(worldIn, 1, 1, Items.FISH);
    this.setSize(1.5F, 1.8125F);
    setBaseHealth(12);
    setBaseAttack(2);
    setBaseSpeed(0.3);
    setBaseKnockback(0.1);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 29
Project: MobHunter   File: EntityGenprey.java   View source code 6 votes vote down vote up
public EntityGenprey(World worldIn)
{
    super(worldIn, 1, 1);
    this.setSize(1.5F, 1.8125F);
    setBaseHealth(12);
    setBaseAttack(2);
    setBaseSpeed(0.3);
    setBaseKnockback(0.1);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 30
Project: MobHunter   File: EntityVelocidrome.java   View source code 6 votes vote down vote up
public EntityVelocidrome(World worldIn)
{
    super(worldIn, Config.scaleMin*0.75f, Config.scaleMax*0.75f);
    this.setSize(2.25F, 2.5F);
    setBaseHealth(300);
    setBaseAttack(2*1.5);
    setBaseSpeed(0.3*1.5);
    setBaseKnockback(0.5*1.5);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 31
Project: MobHunter   File: EntityIoprey.java   View source code 6 votes vote down vote up
public EntityIoprey(World worldIn)
{
    super(worldIn, 1, 1);
    this.setSize(1.5F, 1.8125F);
    setBaseHealth(15);
    setBaseAttack(2);
    setBaseSpeed(0.3);
    setBaseKnockback(0.1);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask( 4, new EntityAIAttackMeleeAndSpit(this, 1.0D, 200, 16.0f,4.0f, true));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 32
Project: MobHunter   File: EntityGreatJaggi.java   View source code 6 votes vote down vote up
public EntityGreatJaggi(World worldIn)
{
    super(worldIn, Config.scaleMin*0.75f, Config.scaleMax*0.75f);
    this.setSize(2.25F, 2.5F);
    setBaseHealth(390);
    setBaseAttack(2*1.5);
    setBaseSpeed(0.3*1.5);
    setBaseKnockback(0.5*1.5);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 33
Project: MobHunter   File: EntityVelociprey.java   View source code 6 votes vote down vote up
public EntityVelociprey(World worldIn)
{
    super(worldIn, 1,1);
    this.setSize(1.5F, 1.8125F);
    setBaseHealth(10);
    setBaseAttack(2);
    setBaseSpeed(0.3);
    setBaseKnockback(0.1);
    this.tasks.addTask(1, new EntityAILeapAtTarget(this,0.5f));
    this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityAnimal.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWitch.class, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMHHerbivore.class, true));
}
 
Example 34
Project: equidcraft   File: EntityHorseCustom.java   View source code 6 votes vote down vote up
public boolean canMateWith(EntityAnimal otherAnimal)
{
    if (otherAnimal == this)
    {
        return false;
    }
    else if (otherAnimal.getClass() != this.getClass())
    {
        return false;
    }
    else
    {
        EntityHorseCustom entityhorse = (EntityHorseCustom) otherAnimal;

        if (this.canMate() && entityhorse.canMate())
        {
            HorseType horsetype = this.getType();
            HorseType horsetype1 = entityhorse.getType();
            return this.isMale() != entityhorse.isMale() && !this.isSterile() && !entityhorse.isSterile() && (horsetype == horsetype1 || horsetype == HorseType.HORSE && horsetype1 == HorseType.DONKEY || horsetype == HorseType.DONKEY && horsetype1 == HorseType.HORSE);
        }
        else
        {
            return false;
        }
    }
}
 
Example 35
Project: equidcraft   File: EntityAIMateCustom.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 36
Project: PopularMMOS-EpicProportions-Mod   File: EntityPopo.java   View source code 6 votes vote down vote up
private int func_90014_a(EntityAnimal p_90014_1_, EntityAnimal p_90014_2_)
{
    int i = this.func_90013_b(p_90014_1_);
    int j = this.func_90013_b(p_90014_2_);
    this.field_90016_e.getStackInSlot(0).setItemDamage(i);
    this.field_90016_e.getStackInSlot(1).setItemDamage(j);
    ItemStack itemstack = CraftingManager.getInstance().findMatchingRecipe(this.field_90016_e, ((EntityPopo)p_90014_1_).worldObj);
    int k;

    if (itemstack != null && itemstack.getItem() == Items.dye)
    {
        k = itemstack.getItemDamage();
    }
    else
    {
        k = this.worldObj.rand.nextBoolean() ? i : j;
    }

    return k;
}
 
Example 37
Project: PopularMMOS-EpicProportions-Mod   File: EntityKitty.java   View source code 6 votes vote down vote up
/**
 * 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 EntityKitty))
    {
        return false;
    }
    else
    {
    	EntityKitty entitykitty = (EntityKitty)p_70878_1_;
        return !entitykitty.isTamed() ? false : this.isInLove() && entitykitty.isInLove();
    }
}
 
Example 38
Project: ThermalRecycling   File: BreedingItemRegistry.java   View source code 6 votes vote down vote up
private static Class<? extends EntityAnimal> resolveClass(final String entityClass) {
	
	if(!MineTweakerUtil.checkNotNull(entityClass, "Entity class name cannot be null"))
		return null;
	
	if(!MineTweakerUtil.checkArgument(!entityClass.isEmpty(), "Entity class name is invalid"))
		return null;

	final Class<?> clazz = (Class<?>) EntityList.stringToClassMapping.get(entityClass);
	if(!MineTweakerUtil.checkNotNull(clazz, String.format("Unknown entity type '%s'", entityClass)))
		return null;
	
	if(!MineTweakerUtil.checkArgument(!clazz.isAssignableFrom(EntityHorse.class), "Unable to specify breeding items for horses"))
		return null;
	
	final Class<? extends EntityAnimal> animal = clazz.asSubclass(EntityAnimal.class);
	if(!MineTweakerUtil.checkNotNull(animal, "Entity is not an EntityAnimal type"))
		return null;
	
	return animal;
}
 
Example 39
Project: ThermalRecycling   File: BreedingItemManager.java   View source code 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = false)
public void entityInteract(final EntityInteractEvent event) {
	if(event.entityPlayer instanceof EntityPlayerMP && event.target instanceof EntityAnimal) {
		final EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
		final ItemStack heldItem = player.getCurrentEquippedItem();
		if(heldItem != null) {
			final EntityAnimal animal = (EntityAnimal)event.target;
			if(canBreed(animal, player)) {
				final Set<ItemStackKey> possibleFood = foodItems.get(event.target.getClass());
				if(possibleFood != null && possibleFood.contains(ItemStackKey.getCachedKey(heldItem))) {
					if (!event.entityPlayer.capabilities.isCreativeMode) {
						heldItem.stackSize--;
						if (heldItem.stackSize <= 0)
							player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
					}
					animal.func_146082_f(player);
				}
			}
		}
	}
}
 
Example 40
Project: Skills   File: CombatBase.java   View source code 6 votes vote down vote up
public float getParrySkill(Entity target)
{
	if(target instanceof EntityPlayer)
	{
		SkillTreeBase parry = SkillTrackerData.get((EntityPlayer) target).GetSkillByID("parry");
		return parry != null ? parry.getSkillLevel() : 0;
	}
	else if (target instanceof EntityMob)
	{
		//TODO Give Mobs a Defense
		return EntityMobsExt.get((EntityMob)target).parry;
	}
	else if(target instanceof EntityAnimal)
	{
		return EntityAnimalExt.get((EntityAnimal)target).parry;
	}
	
	return 0;
}