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));
}
}
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;
}
Aggregations