Search in sources :

Example 11 with Faction

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
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IServerWorld(net.minecraft.world.IServerWorld) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) EffectInstance(net.minecraft.potion.EffectInstance) Faction(team.cqr.cqrepoured.faction.Faction)

Example 12 with Faction

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

Example 13 with Faction

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

Example 14 with Faction

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

Example 15 with Faction

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();
    }
}
Also used : Faction(team.cqr.cqrepoured.faction.Faction) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Aggregations

Faction (team.cqr.cqrepoured.faction.Faction)18 LivingEntity (net.minecraft.entity.LivingEntity)12 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 Entity (net.minecraft.entity.Entity)4 EffectInstance (net.minecraft.potion.EffectInstance)3 Vector3d (net.minecraft.util.math.vector.Vector3d)3 EDefaultFaction (team.cqr.cqrepoured.faction.EDefaultFaction)3 ArrayList (java.util.ArrayList)1 CommandException (net.minecraft.command.CommandException)1 WrongUsageException (net.minecraft.command.WrongUsageException)1 MonsterEntity (net.minecraft.entity.monster.MonsterEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 AbstractArrowEntity (net.minecraft.entity.projectile.AbstractArrowEntity)1 SpectralArrowEntity (net.minecraft.entity.projectile.SpectralArrowEntity)1 ThrowableEntity (net.minecraft.entity.projectile.ThrowableEntity)1 AxeItem (net.minecraft.item.AxeItem)1 ItemStack (net.minecraft.item.ItemStack)1 ShieldItem (net.minecraft.item.ShieldItem)1 ResourceLocation (net.minecraft.util.ResourceLocation)1