use of net.tropicraft.core.common.entity.underdasea.atlantoku.EntityTropicraftWaterBase in project Tropicraft by Tropicraft.
the class EntityAISwimAvoidPredator method updateTask.
@Override
public void updateTask() {
super.updateTask();
if (!entity.isAggressing && (entity.ticksExisted) % 20 == 0) {
List<EntityTropicraftWaterBase> ents = entity.world.getEntitiesWithinAABB(EntityTropicraftWaterBase.class, new AxisAlignedBB(entity.getPosition()).grow(distanceToAvoid));
for (int i = 0; i < ents.size(); i++) {
EntityTropicraftWaterBase f = ents.get(i);
if (entity.getDistanceSq(f) < this.distanceToAvoid && entity.canEntityBeSeen(f)) {
if (f.aggressTarget != null) {
if (f.aggressTarget.equals(entity)) {
entity.fleeEntity(f);
entity.isPanicking = true;
// System.out.println("Avoiding!");
break;
}
}
if (f instanceof IPredatorDiet) {
if (Arrays.asList(((IPredatorDiet) f).getPreyClasses()).contains(entity.getClass())) {
entity.fleeEntity(f);
entity.isPanicking = true;
break;
}
}
}
}
}
}
Aggregations