Search in sources :

Example 1 with EntitySpectreLordCurse

use of team.cqr.cqrepoured.entity.boss.spectrelord.EntitySpectreLordCurse in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAISpectreLordChannelHate method resetTask.

@Override
public void resetTask() {
    super.resetTask();
    for (EntitySpectreLordCurse curse : this.curses) {
        curse.remove();
    }
    this.curses.clear();
    this.healthLost = 0.0F;
    this.lastHealth = 0.0F;
}
Also used : EntitySpectreLordCurse(team.cqr.cqrepoured.entity.boss.spectrelord.EntitySpectreLordCurse)

Example 2 with EntitySpectreLordCurse

use of team.cqr.cqrepoured.entity.boss.spectrelord.EntitySpectreLordCurse 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);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) Faction(team.cqr.cqrepoured.faction.Faction) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EntitySpectreLordCurse(team.cqr.cqrepoured.entity.boss.spectrelord.EntitySpectreLordCurse)

Aggregations

EntitySpectreLordCurse (team.cqr.cqrepoured.entity.boss.spectrelord.EntitySpectreLordCurse)2 LivingEntity (net.minecraft.entity.LivingEntity)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 Faction (team.cqr.cqrepoured.faction.Faction)1