Search in sources :

Example 11 with ArmorStandEntity

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();
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) ArmorStandEntity(net.minecraft.entity.item.ArmorStandEntity)

Aggregations

ArmorStandEntity (net.minecraft.entity.item.ArmorStandEntity)11 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 Entity (net.minecraft.entity.Entity)3 LivingEntity (net.minecraft.entity.LivingEntity)3 ItemFrameEntity (net.minecraft.entity.item.ItemFrameEntity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 net.minecraft.item (net.minecraft.item)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 Lists (com.google.common.collect.Lists)2 MinecoloniesAPIProxy (com.minecolonies.api.MinecoloniesAPIProxy)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Compatibility (com.minecolonies.api.compatibility.Compatibility)2 ItemStorage (com.minecolonies.api.crafting.ItemStorage)2 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)2 ModItems (com.minecolonies.api.items.ModItems)2 ModTags.fungi (com.minecolonies.api.items.ModTags.fungi)2 FUEL_SLOT (com.minecolonies.api.util.constant.Constants.FUEL_SLOT)2 SMELTABLE_SLOT (com.minecolonies.api.util.constant.Constants.SMELTABLE_SLOT)2 IToolType (com.minecolonies.api.util.constant.IToolType)2