Search in sources :

Example 1 with EntityAINearestAttackableTarget

use of net.minecraft.entity.ai.EntityAINearestAttackableTarget in project ArsMagica2 by Mithion.

the class AM2Boss method initAI.

/**
	 * This contains the default AI tasks.  To add new ones, override {@link #initSpecificAI()}
	 */
protected void initAI() {
    this.getNavigator().setBreakDoors(true);
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLightMage.class, 0, true));
    initSpecificAI();
}
Also used : EntityAISwimming(net.minecraft.entity.ai.EntityAISwimming) EntityLightMage(am2.entities.EntityLightMage) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget)

Example 2 with EntityAINearestAttackableTarget

use of net.minecraft.entity.ai.EntityAINearestAttackableTarget in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_PlayerFaction.

public static void makeSummon_PlayerFaction(EntityCreature entityliving, EntityPlayer player, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData) && ExtendedProperties.For(player).getCanHaveMoreSummons()) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        boolean addMeleeAttack = false;
        ArrayList<EntityAITaskEntry> toRemove = new ArrayList<EntityAITaskEntry>();
        for (Object task : entityliving.tasks.taskEntries) {
            EntityAITaskEntry base = (EntityAITaskEntry) task;
            if (base.action instanceof EntityAIAttackOnCollide) {
                toRemove.add(base);
                addMeleeAttack = true;
            }
        }
        entityliving.tasks.taskEntries.removeAll(toRemove);
        if (storeForRevert)
            storedAITasks.put(entityliving.getEntityId(), toRemove);
        if (addMeleeAttack) {
            float speed = entityliving.getAIMoveSpeed();
            if (speed <= 0)
                speed = 1.0f;
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntityMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, IMob.class, speed, true));
            entityliving.tasks.addTask(3, new EntityAIAttackOnCollide(entityliving, EntitySlime.class, speed, true));
        }
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityMob.class, 0, true, false, SummonEntitySelector.instance));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntitySlime.class, 0, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityGhast.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityPlayer)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        if (entityliving instanceof EntityTameable) {
            ((EntityTameable) entityliving).setTamed(true);
            ((EntityTameable) entityliving).func_152115_b(player.getCommandSenderName());
        }
        entityliving.getEntityData().setBoolean(isSummonKey, true);
        ExtendedProperties.For(player).addSummon(entityliving);
    }
}
Also used : EntitySlime(net.minecraft.entity.monster.EntitySlime) ArrayList(java.util.ArrayList) EntityGhast(net.minecraft.entity.monster.EntityGhast) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget) EntityMob(net.minecraft.entity.monster.EntityMob) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) IMob(net.minecraft.entity.monster.IMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Example 3 with EntityAINearestAttackableTarget

use of net.minecraft.entity.ai.EntityAINearestAttackableTarget in project NetherEx by LogicTechCorp.

the class EntityBrute method initEntityAI.

@Override
protected void initEntityAI() {
    tasks.addTask(0, new EntityAISwimming(this));
    tasks.addTask(1, new EntityAIWatchClosest(this, EntityPlayer.class, 64.0F));
    tasks.addTask(2, new EntityAIWander(this, 1.0D, 360));
    targetTasks.addTask(0, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
}
Also used : EntityAIWatchClosest(net.minecraft.entity.ai.EntityAIWatchClosest) EntityAISwimming(net.minecraft.entity.ai.EntityAISwimming) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAIWander(net.minecraft.entity.ai.EntityAIWander) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget)

Example 4 with EntityAINearestAttackableTarget

use of net.minecraft.entity.ai.EntityAINearestAttackableTarget in project ArsMagica2 by Mithion.

the class EntityUtilities method makeSummon_MonsterFaction.

public static void makeSummon_MonsterFaction(EntityCreature entityliving, boolean storeForRevert) {
    if (isAIEnabled(entityliving) && !(entityliving instanceof IBossDisplayData)) {
        if (storeForRevert)
            storedTasks.put(entityliving.getEntityId(), new ArrayList(entityliving.targetTasks.taskEntries));
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.addTask(1, new EntityAIHurtByTarget(entityliving, true));
        entityliving.targetTasks.addTask(2, new EntityAINearestAttackableTarget(entityliving, EntityPlayer.class, 0, true));
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null && entityliving.getAttackTarget() instanceof EntityMob)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        entityliving.getEntityData().setBoolean(isSummonKey, true);
    }
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) IBossDisplayData(net.minecraft.entity.boss.IBossDisplayData) ArrayList(java.util.ArrayList) EntityAIHurtByTarget(net.minecraft.entity.ai.EntityAIHurtByTarget) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAINearestAttackableTarget(net.minecraft.entity.ai.EntityAINearestAttackableTarget)

Aggregations

EntityAINearestAttackableTarget (net.minecraft.entity.ai.EntityAINearestAttackableTarget)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 EntityAIHurtByTarget (net.minecraft.entity.ai.EntityAIHurtByTarget)3 ArrayList (java.util.ArrayList)2 EntityAISwimming (net.minecraft.entity.ai.EntityAISwimming)2 IBossDisplayData (net.minecraft.entity.boss.IBossDisplayData)2 EntityMob (net.minecraft.entity.monster.EntityMob)2 EntityLightMage (am2.entities.EntityLightMage)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityAIWander (net.minecraft.entity.ai.EntityAIWander)1 EntityAIWatchClosest (net.minecraft.entity.ai.EntityAIWatchClosest)1 EntityGhast (net.minecraft.entity.monster.EntityGhast)1 EntitySlime (net.minecraft.entity.monster.EntitySlime)1 IMob (net.minecraft.entity.monster.IMob)1 EntityTameable (net.minecraft.entity.passive.EntityTameable)1