Search in sources :

Example 1 with EntityAISummonFollowOwner

use of am2.entities.ai.EntityAISummonFollowOwner in project ArsMagica2 by Mithion.

the class EntityUtilities method setOwner.

public static void setOwner(EntityLivingBase entityliving, EntityLivingBase owner) {
    if (owner == null) {
        entityliving.getEntityData().removeTag(summonOwnerKey);
        return;
    }
    entityliving.getEntityData().setInteger(summonOwnerKey, owner.getEntityId());
    if (entityliving instanceof EntityCreature) {
        float speed = entityliving.getAIMoveSpeed();
        if (speed <= 0)
            speed = 1.0f;
        ((EntityCreature) entityliving).tasks.addTask(1, new EntityAISummonFollowOwner((EntityCreature) entityliving, speed, 10, 20));
    }
}
Also used : EntityAISummonFollowOwner(am2.entities.ai.EntityAISummonFollowOwner) EntityCreature(net.minecraft.entity.EntityCreature)

Example 2 with EntityAISummonFollowOwner

use of am2.entities.ai.EntityAISummonFollowOwner in project ArsMagica2 by Mithion.

the class EntityUtilities method revertAI.

public static boolean revertAI(EntityCreature entityliving) {
    int ownerID = getOwner(entityliving);
    Entity owner = entityliving.worldObj.getEntityByID(ownerID);
    if (owner != null && owner instanceof EntityLivingBase) {
        ExtendedProperties.For((EntityLivingBase) owner).removeSummon();
        if (ExtendedProperties.For((EntityLivingBase) owner).isManaLinkedTo(entityliving)) {
            ExtendedProperties.For((EntityLivingBase) owner).updateManaLink(entityliving);
            ExtendedProperties.For((EntityLivingBase) owner).forceSync();
        }
    }
    entityliving.getEntityData().setBoolean(isSummonKey, false);
    setOwner(entityliving, null);
    if (storedTasks.containsKey(entityliving.getEntityId())) {
        entityliving.targetTasks.taskEntries.clear();
        entityliving.targetTasks.taskEntries.addAll(storedTasks.get(entityliving.getEntityId()));
        storedTasks.remove(entityliving.getEntityId());
        if (storedAITasks.get(entityliving.getEntityId()) != null) {
            ArrayList<EntityAITaskEntry> toRemove = new ArrayList<EntityAITaskEntry>();
            for (Object task : entityliving.tasks.taskEntries) {
                EntityAITaskEntry base = (EntityAITaskEntry) task;
                if (base.action instanceof EntityAIAttackOnCollide || base.action instanceof EntityAISummonFollowOwner) {
                    toRemove.add(base);
                }
            }
            entityliving.tasks.taskEntries.removeAll(toRemove);
            entityliving.tasks.taskEntries.addAll(storedAITasks.get(entityliving.getEntityId()));
            storedAITasks.remove(entityliving.getEntityId());
        }
        if (!entityliving.worldObj.isRemote && entityliving.getAttackTarget() != null)
            AMCore.proxy.addDeferredTargetSet(entityliving, null);
        if (entityliving instanceof EntityTameable) {
            ((EntityTameable) entityliving).setTamed(false);
        }
        return true;
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityAIAttackOnCollide(net.minecraft.entity.ai.EntityAIAttackOnCollide) EntityLivingBase(net.minecraft.entity.EntityLivingBase) ArrayList(java.util.ArrayList) EntityAISummonFollowOwner(am2.entities.ai.EntityAISummonFollowOwner) EntityAITaskEntry(net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry) EntityTameable(net.minecraft.entity.passive.EntityTameable)

Aggregations

EntityAISummonFollowOwner (am2.entities.ai.EntityAISummonFollowOwner)2 ArrayList (java.util.ArrayList)1 Entity (net.minecraft.entity.Entity)1 EntityCreature (net.minecraft.entity.EntityCreature)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityAIAttackOnCollide (net.minecraft.entity.ai.EntityAIAttackOnCollide)1 EntityAITaskEntry (net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry)1 EntityTameable (net.minecraft.entity.passive.EntityTameable)1 TileEntity (net.minecraft.tileentity.TileEntity)1