Search in sources :

Example 1 with Helper

use of com.jacob_vejvoda.infernal_mobs.Helper in project InfernalMobs by NyaaCat.

the class AbilityProjectile method perCycleEffect.

@Override
public void perCycleEffect(LivingEntity mobEntity, Mob mob) {
    if (!Helper.possibility(perCycleChance))
        return;
    List<Player> nearbyPlayers = mobEntity.getNearbyEntities(effectiveRange, effectiveRange, effectiveRange).stream().filter(entity -> entity instanceof Player).map(entity -> ((Player) entity)).filter(Helper::validGamemode).collect(Collectors.toList());
    if (!nearbyPlayers.isEmpty()) {
        nearbyPlayers.forEach(player -> {
            if (!mobEntity.hasLineOfSight(player))
                return;
            Vector vector = Helper.unitDirectionVector(mobEntity.getEyeLocation().toVector(), player.getEyeLocation().toVector()).multiply(mainSpeed);
            Projectile pro = launch(mobEntity, player, vector, false);
            postLaunch(pro, mobEntity, player);
            launchExtraProjectiles(vector, mobEntity, player);
        });
    }
}
Also used : Vector(org.bukkit.util.Vector) Helper(com.jacob_vejvoda.infernal_mobs.Helper) GameMode(org.bukkit.GameMode) List(java.util.List) Mob(com.jacob_vejvoda.infernal_mobs.persist.Mob) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Collectors(java.util.stream.Collectors) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) org.bukkit.entity(org.bukkit.entity) Vector(org.bukkit.util.Vector)

Aggregations

Helper (com.jacob_vejvoda.infernal_mobs.Helper)1 Mob (com.jacob_vejvoda.infernal_mobs.persist.Mob)1 List (java.util.List)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Collectors (java.util.stream.Collectors)1 GameMode (org.bukkit.GameMode)1 org.bukkit.entity (org.bukkit.entity)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1 Vector (org.bukkit.util.Vector)1