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