Search in sources :

Example 1 with WitherSkull

use of org.bukkit.entity.WitherSkull in project InfernalMobs by NyaaCat.

the class AbilityNecromancer method perCycleEffect.

@Override
public void perCycleEffect(LivingEntity mobEntity, Mob mob) {
    if (Helper.possibility(0.9))
        return;
    Location mobLoc = mobEntity.getLocation();
    List<Player> players = mobLoc.getWorld().getPlayers().stream().filter(p -> p.getLocation().distanceSquared(mobLoc) <= EFFECTIVE_RANGE_SQUARED).filter(p -> p.getGameMode() != GameMode.CREATIVE).collect(Collectors.toList());
    Player victim = Helper.randomItem(players);
    if (victim == null)
        return;
    WitherSkull w = mobEntity.launchProjectile(WitherSkull.class, Helper.unitDirectionVector(mobEntity.getEyeLocation().toVector(), victim.getEyeLocation().toVector()));
    Helper.removeEntityLater(w, 30);
// TODO WitherSkull tracing player
}
Also used : Helper(com.jacob_vejvoda.infernal_mobs.Helper) GameMode(org.bukkit.GameMode) List(java.util.List) Location(org.bukkit.Location) Mob(com.jacob_vejvoda.infernal_mobs.persist.Mob) Fireball(org.bukkit.entity.Fireball) Player(org.bukkit.entity.Player) LivingEntity(org.bukkit.entity.LivingEntity) WitherSkull(org.bukkit.entity.WitherSkull) Collectors(java.util.stream.Collectors) EntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent) Player(org.bukkit.entity.Player) WitherSkull(org.bukkit.entity.WitherSkull) Location(org.bukkit.Location)

Example 2 with WitherSkull

use of org.bukkit.entity.WitherSkull in project InfernalMobs by NyaaCat.

the class AbilityNecromancer method onPlayerAttack.

@Override
public void onPlayerAttack(LivingEntity mobEntity, Mob mob, Player attacker, boolean isDirectAttack, EntityDamageByEntityEvent ev) {
    if (isDirectAttack) {
        if (Helper.possibility(0.5))
            return;
        WitherSkull w = mobEntity.launchProjectile(WitherSkull.class, Helper.unitDirectionVector(mobEntity.getEyeLocation().toVector(), attacker.getEyeLocation().toVector()));
        Helper.removeEntityLater(w, 30);
    // TODO WitherSkull tracing player
    }
}
Also used : WitherSkull(org.bukkit.entity.WitherSkull)

Aggregations

WitherSkull (org.bukkit.entity.WitherSkull)2 Helper (com.jacob_vejvoda.infernal_mobs.Helper)1 Mob (com.jacob_vejvoda.infernal_mobs.persist.Mob)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 GameMode (org.bukkit.GameMode)1 Location (org.bukkit.Location)1 Fireball (org.bukkit.entity.Fireball)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Player (org.bukkit.entity.Player)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1