use of net.minecraft.entity.item.ArmorStandEntity in project minecolonies by ldtteam.
the class KnightCombatAI method doAoeAttack.
/**
* Does an aoe attack if researched
*
* @param source normal attack damage source
* @param damageToBeDealt normal attack damage to be distributed to targets
*/
private void doAoeAttack(final DamageSource source, final double damageToBeDealt) {
if (user.getCitizenColonyHandler().getColony().getResearchManager().getResearchEffects().getEffectStrength(KNIGHT_WHIRLWIND) > 0 && user.getRandom().nextInt(KNOCKBACK_CHANCE) == 0) {
List<LivingEntity> entities = user.level.getLoadedEntitiesOfClass(LivingEntity.class, user.getBoundingBox().inflate(2.0D, 0.5D, 2.0D));
for (LivingEntity livingentity : entities) {
if (livingentity != user && isEntityValidTarget(livingentity) && (!(livingentity instanceof ArmorStandEntity))) {
livingentity.knockback(2F, MathHelper.sin(livingentity.yRot * ((float) Math.PI)), (-MathHelper.cos(livingentity.yRot * ((float) Math.PI))));
livingentity.hurt(source, (float) (damageToBeDealt / entities.size()));
}
}
user.level.playSound(null, user.getX(), user.getY(), user.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, user.getSoundSource(), 1.0F, 1.0F);
double d0 = (double) (-MathHelper.sin(user.yRot * ((float) Math.PI / 180)));
double d1 = (double) MathHelper.cos(user.yRot * ((float) Math.PI / 180));
if (user.level instanceof ServerWorld) {
((ServerWorld) user.level).sendParticles(ParticleTypes.SWEEP_ATTACK, user.getX() + d0, user.getY(0.5D), user.getZ() + d1, 2, d0, 0.0D, d1, 0.0D);
}
lastAoeUseTime = user.level.getGameTime();
}
}
Aggregations