Search in sources :

Example 1 with Faction

use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAISpectreLordDash method startChargingSpell.

@Override
public void startChargingSpell() {
    super.startChargingSpell();
    Faction faction = this.entity.getFaction();
    if (faction == null) {
        this.target = this.entity.getAttackTarget();
    } else {
        AxisAlignedBB aabb = new AxisAlignedBB(this.entity.posX - 16.0D, this.entity.posY - 2.0D, this.entity.posZ - 16.0D, this.entity.posX + 16.0D, this.entity.posY + this.entity.height + 2.0D, this.entity.posZ + 16.0D);
        List<LivingEntity> list = this.world.getEntitiesWithinAABB(LivingEntity.class, aabb, e -> TargetUtil.PREDICATE_ATTACK_TARGET.apply(e) && faction.isEnemy(e));
        if (list.isEmpty()) {
            this.target = this.entity.getAttackTarget();
        } else {
            this.target = list.get(this.random.nextInt(list.size()));
            this.entity.setTarget(this.target);
        }
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) Faction(team.cqr.cqrepoured.faction.Faction)

Example 2 with Faction

use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAISpectreLordDash method dashToTarget.

private void dashToTarget() {
    Vector3d vec1 = this.entity.position();
    boolean noClip = this.entity.noClip;
    if (!noClip) {
        Vector3d start = new Vector3d(this.entity.posX, this.entity.posY + this.entity.getEyeHeight(), this.entity.posZ);
        Vector3d end = start.add(this.targetDirection);
        if (this.world.rayTraceBlocks(start, end, false, true, false) == null && !this.world.collidesWithAnyBlock(this.entity.getEntityBoundingBox().offset(this.targetDirection))) {
            this.entity.noClip = true;
        }
    }
    this.entity.move(MoverType.SELF, this.targetDirection.x, this.targetDirection.y, this.targetDirection.z);
    this.entity.noClip = noClip;
    Vector3d vec2 = this.entity.position();
    Vector3d vec3 = new Vector3d(-this.dashWidth, 0.0D, 0.0D);
    Vector3d vec4 = new Vector3d(this.dashWidth, this.entity.height, vec2.subtract(vec1).length());
    BoundingBox bb = new BoundingBox(vec3, vec4, this.yawRadian, 0.0D, vec1);
    List<LivingEntity> list = BoundingBox.getEntitiesInsideBB(this.world, this.entity, LivingEntity.class, bb);
    Faction faction = this.entity.getFaction();
    for (LivingEntity entity : list) {
        if (!TargetUtil.PREDICATE_ATTACK_TARGET.apply(entity)) {
            continue;
        }
        if (faction != null && faction.isAlly(entity)) {
            continue;
        }
        entity.attackEntityFrom(DamageSource.causeMobDamage(this.entity).setDamageBypassesArmor(), 10.0F);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) BoundingBox(team.cqr.cqrepoured.util.math.BoundingBox) Faction(team.cqr.cqrepoured.faction.Faction)

Example 3 with Faction

use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAIAntiAirSpellWalker method shouldExecute.

@Override
public boolean shouldExecute() {
    if (this.random.nextBoolean()) {
        return false;
    }
    if (!super.shouldExecute()) {
        return false;
    }
    LivingEntity attackTarget = this.entity.getTarget();
    Faction faction = this.entity.getFaction();
    if ((faction != null && faction.isAlly(attackTarget)) || this.entity.getLeader() == attackTarget) {
        return false;
    }
    if (attackTarget.isPassenger()) {
        Entity entity = attackTarget.getVehicle();
        if (entity instanceof LivingEntity) {
            attackTarget = (LivingEntity) entity;
        }
    }
    return EntityUtil.isEntityFlying(attackTarget);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) Faction(team.cqr.cqrepoured.faction.Faction)

Example 4 with Faction

use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAISpectreLordChannelHate method castSpell.

@Override
public void castSpell() {
    super.castSpell();
    float f = this.entity.getHealth() / this.entity.getMaxHealth();
    this.healthLost += Math.max(this.lastHealth - f, 0.0F);
    this.lastHealth = f;
    if (this.tick == this.chargingTicks + this.castingTicks - 1) {
        this.entity.addPotionEffect(new EffectInstance(Effects.SPEED, 200, 1, false, true));
        this.entity.addPotionEffect(new EffectInstance(Effects.STRENGTH, 200, 1, false, true));
        AxisAlignedBB aabb = new AxisAlignedBB(this.entity.posX - 32.0D, this.entity.posY - 8.0D, this.entity.posZ - 32.0D, this.entity.posX + 32.0D, this.entity.posY + this.entity.height + 8.0D, this.entity.posZ + 32.0D);
        Faction faction = this.entity.getFaction();
        for (LivingEntity e : this.world.getEntitiesWithinAABB(LivingEntity.class, aabb, e -> TargetUtil.PREDICATE_ATTACK_TARGET.apply(e) && (faction == null || !faction.isAlly(e)))) {
            e.attackEntityFrom(DamageSource.causeMobDamage(this.entity).setDamageBypassesArmor(), 4.0F);
            e.addPotionEffect(new EffectInstance(Effects.WEAKNESS, 200, 1, false, true));
        }
        this.entity.playSound(SoundEvents.EVOCATION_ILLAGER_CAST_SPELL, 1.0F, 0.9F + this.random.nextFloat() * 0.2F);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) LivingEntity(net.minecraft.entity.LivingEntity) EffectInstance(net.minecraft.potion.EffectInstance) Faction(team.cqr.cqrepoured.faction.Faction)

Example 5 with Faction

use of team.cqr.cqrepoured.faction.Faction in project ChocolateQuestRepoured by TeamChocoQuest.

the class AbstractEntityCQR method setFaction.

public void setFaction(String newFac, boolean ignoreCTS) {
    // TODO: Update faction on client too!!
    if (!this.level.isClientSide) {
        Faction faction = FactionRegistry.instance(this).getFactionInstance(newFac);
        if (faction != null) {
            this.factionInstance = null;
            this.factionName = newFac;
            if (!ignoreCTS) {
                ResourceLocation rs = faction.getRandomTextureFor(this);
                if (rs != null) {
                    this.setCustomTexture(rs);
                }
            }
            this.entityData.set(FACTION_OVERRIDE_SYNC, newFac);
        }
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) Faction(team.cqr.cqrepoured.faction.Faction) EDefaultFaction(team.cqr.cqrepoured.faction.EDefaultFaction)

Aggregations

Faction (team.cqr.cqrepoured.faction.Faction)18 LivingEntity (net.minecraft.entity.LivingEntity)13 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)8 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 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 ResourceLocation (net.minecraft.util.ResourceLocation)2 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