use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAISpectreLordSummonIllusions method absorbIllusions.
private void absorbIllusions() {
super.startCastingSpell();
float heal = 0.05F;
for (Entity e : this.entity.getSummonedEntities()) {
if (e.distanceToSqr(this.entity) <= 32.0D * 32.0D) {
heal += 0.05F;
e.remove();
((ServerWorld) this.world).addParticle(ParticleTypes.INSTANT_EFFECT, e.getX(), e.getY() + e.getBbHeight() * 0.5D, e.getZ(), /*4,*/
0.25D, 0.25D, 0.25D);
}
}
AxisAlignedBB aabb = new AxisAlignedBB(this.entity.getX() - 8.0D, this.entity.getY() - 0.5D, this.entity.getZ() - 8.0D, this.entity.getX() + 8.0D, this.entity.getY() + this.entity.getBbHeight() + 0.5D, this.entity.getZ() + 8.0D);
Faction faction = this.entity.getFaction();
for (LivingEntity e : this.world.getEntitiesOfClass(LivingEntity.class, aabb, e -> TargetUtil.PREDICATE_ATTACK_TARGET.apply(e) && (faction == null || !faction.isAlly(e)))) {
heal += 0.05F;
e.hurt(DamageSource.mobAttack(this.entity).bypassArmor(), 4.0F);
e.addEffect(new EffectInstance(Effects.MOVEMENT_SLOWDOWN, 100, 1, false, false));
}
this.entity.heal(this.entity.getMaxHealth() * heal);
// TODO spawn shockwave entity
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAISpectreLordChannelHate method startCastingSpell.
@Override
public void startCastingSpell() {
super.startCastingSpell();
this.lastHealth = this.entity.getHealth() / this.entity.getMaxHealth();
AxisAlignedBB aabb = new AxisAlignedBB(this.entity.getX() - 32.0D, this.entity.getY() - 8.0D, this.entity.getZ() - 32.0D, this.entity.getX() + 32.0D, this.entity.getY() + this.entity.getBbHeight() + 8.0D, this.entity.getZ() + 32.0D);
Faction faction = this.entity.getFaction();
List<LivingEntity> list = this.world.getEntitiesOfClass(LivingEntity.class, aabb, e -> TargetUtil.PREDICATE_ATTACK_TARGET.apply(e) && (faction == null || !faction.isAlly(e)));
list.sort((e1, e2) -> {
if (faction != null) {
boolean flag1 = faction.isEnemy(e1);
boolean flag2 = faction.isEnemy(e2);
if (flag1 && !flag2) {
return -1;
}
if (!flag1 && flag2) {
return 1;
}
}
boolean flag1 = e1 instanceof PlayerEntity;
boolean flag2 = e2 instanceof PlayerEntity;
if (flag1 && !flag2) {
return -1;
}
if (!flag1 && flag2) {
return 1;
}
double d1 = this.entity.distanceToSqr(e1);
double d2 = this.entity.distanceToSqr(e2);
if (d1 < d2) {
return -1;
}
if (d1 > d2) {
return 1;
}
return 0;
});
for (int i = 0; i < 8 && i < list.size(); i++) {
LivingEntity e = list.get(i);
EntitySpectreLordCurse curse = new EntitySpectreLordCurse(this.world, this.entity, e);
curse.setPos(this.entity.getX(), this.entity.getY(), this.entity.getZ());
this.world.addFreshEntity(curse);
this.curses.add(curse);
}
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAISpectreLordIllusionHeal method startChargingSpell.
@Override
public void startChargingSpell() {
super.startChargingSpell();
AxisAlignedBB aabb = new AxisAlignedBB(this.entity.getX() - 24.0D, this.entity.getY() - 2.0D, this.entity.getZ() - 24.0D, this.entity.getX() + 24.0D, this.entity.getY() + this.entity.getBbHeight() + 2.0D, this.entity.getZ() + 24.0D);
Faction faction = this.entity.getFaction();
List<LivingEntity> alliesToHeal = this.world.getEntitiesOfClass(LivingEntity.class, aabb, e -> {
if (e == this.entity) {
return false;
}
if (e.getHealth() / e.getMaxHealth() > 0.9F) {
return false;
}
if (!faction.isAlly(e)) {
return false;
}
return this.entity.canSee(e);
});
this.target = TargetUtil.getNearestEntity(this.entity, alliesToHeal);
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAISpectreLordIllusionHeal method shouldExecute.
@Override
public boolean shouldExecute() {
if (!super.shouldExecute()) {
return false;
}
AxisAlignedBB aabb = new AxisAlignedBB(this.entity.getX() - 24.0D, this.entity.getY() - 2.0D, this.entity.getZ() - 24.0D, this.entity.getX() + 24.0D, this.entity.getY() + this.entity.getBbHeight() + 2.0D, this.entity.getZ() + 24.0D);
Faction faction = this.entity.getFaction();
List<LivingEntity> alliesToHeal = this.world.getEntitiesOfClass(LivingEntity.class, aabb, e -> {
if (e == this.entity) {
return false;
}
if (e.getHealth() / e.getMaxHealth() > 0.9F) {
return false;
}
if (faction == null || !faction.isAlly(e)) {
return false;
}
return this.entity.canSee(e);
});
return !alliesToHeal.isEmpty();
}
use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.
the class EntityAIHurtByTarget method start.
@Override
public void start() {
this.prevRevengeTimer = this.entity.getLastHurtByMobTimestamp();
this.trySetAttackTarget(this.entity);
Faction faction = this.entity.getFaction();
if (faction != null && faction.isEnemy(this.attackTarget) && !(this.entity.getLeader() instanceof PlayerEntity)) {
this.callForHelp();
}
}
Aggregations