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