use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class ZombieNecronomicon method spawnReinforcements.
private void spawnReinforcements(EliteEntity eliteEntity, LivingEntity targetted, ZombieNecronomicon zombieNecronomicon) {
LivingEntity targetter = eliteEntity.getLivingEntity();
new BukkitRunnable() {
final ArrayList<Entity> entityList = new ArrayList<>();
@Override
public void run() {
if (!eliteEntity.isValid() || !targetted.isValid() || !targetter.isValid() || targetted.getWorld() != targetter.getWorld() || targetted.getLocation().distance(targetter.getLocation()) > 30) {
for (Entity entity : entityList) if (entity.isValid())
entity.remove();
if (eliteEntity.isValid())
targetter.setAI(true);
cancel();
return;
}
int randomizedNumber = ThreadLocalRandom.current().nextInt(5) + 1;
entityList.removeIf(currentEntity -> !currentEntity.isValid());
if (entityList.size() < 11) {
targetter.setAI(false);
if (!zombieNecronomicon.isFiring())
necronomiconVisualEffect(eliteEntity, zombieNecronomicon);
if (randomizedNumber < 5) {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_zombie.yml");
if (customBossEntity == null) {
new WarningMessage("necronomicon_zombie.yml is not valid!");
return;
}
customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
if (!customBossEntity.getLivingEntity().isValid()) {
targetter.setAI(true);
cancel();
targetter.setAI(true);
cancel();
return;
}
customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
eliteEntity.addReinforcement(customBossEntity);
entityList.add(customBossEntity.getLivingEntity());
} else {
CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity("necronomicon_skeleton.yml");
if (customBossEntity == null) {
new WarningMessage("necronomicon_skeleton.yml is not valid!");
targetter.setAI(true);
cancel();
return;
}
customBossEntity.spawn(targetter.getLocation(), eliteEntity.getLevel(), false);
if (!customBossEntity.getLivingEntity().isValid()) {
targetter.setAI(true);
cancel();
return;
}
customBossEntity.getLivingEntity().setVelocity(new Vector((ThreadLocalRandom.current().nextDouble() - 0.5) / 30, 0.5, (ThreadLocalRandom.current().nextDouble() - 0.5) / 30));
eliteEntity.addReinforcement(customBossEntity);
entityList.add(customBossEntity.getLivingEntity());
}
} else
targetter.setAI(true);
}
}.runTaskTimer(MetadataHandler.PLUGIN, 20 * 3L, 20 * 3L);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class Bombardment method activate.
public void activate(EliteEntity eliteEntity) {
if (isActive)
return;
isActive = true;
task = new BukkitRunnable() {
int counter = 0;
@Override
public void run() {
counter++;
if (stopCondition(eliteEntity))
return;
if (firing || isInCooldown(eliteEntity))
return;
if (ThreadLocalRandom.current().nextDouble() > 0.1)
return;
if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON)) {
EnderDragon.Phase phase = ((EnderDragon) eliteEntity.getLivingEntity()).getPhase();
if (phase.equals(EnderDragon.Phase.DYING) || phase.equals(EnderDragon.Phase.HOVER) || phase.equals(EnderDragon.Phase.ROAR_BEFORE_ATTACK) || phase.equals(EnderDragon.Phase.FLY_TO_PORTAL) || phase.equals(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET)) {
return;
}
}
for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 100, 10)) {
if (entity.getType().equals(EntityType.PLAYER)) {
firing = true;
fire(eliteEntity);
return;
}
}
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 5);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class CustomSummonPower method onCombatEnterSummonReinforcement.
private void onCombatEnterSummonReinforcement(EliteEntity spawningEntity) {
for (CustomBossReinforcement customBossReinforcement : customBossReinforcements) {
if (!customBossReinforcement.summonType.equals(SummonType.ON_COMBAT_ENTER))
continue;
if (customBossReinforcement.bossFileName != null) {
summonReinforcement(spawningEntity, customBossReinforcement);
} else {
Location spawnLocation = getFinalSpawnLocation(spawningEntity, customBossReinforcement.spawnLocationOffset);
Entity entity = spawnLocation.getWorld().spawnEntity(spawnLocation, customBossReinforcement.entityType);
entity.getPersistentDataContainer().set(new NamespacedKey(MetadataHandler.PLUGIN, "eliteCrystal"), PersistentDataType.STRING, "eliteCrystal");
entity.setPersistent(false);
CrashFix.persistentTracker(entity);
if (entity instanceof Mob && !spawningEntity.getDamagers().isEmpty()) {
Player target = null;
double damageDealt = 0;
for (Player player : spawningEntity.getDamagers().keySet()) {
if (spawningEntity.getDamagers().get(player) < damageDealt)
continue;
target = player;
damageDealt = spawningEntity.getDamagers().get(player);
}
if (target != null)
((Mob) entity).setTarget(target);
}
if (customBossReinforcement.isLightningRod)
new EnderCrystalLightningRod(spawningEntity, (EnderCrystal) entity);
customBossReinforcement.isSummoned = true;
spawningEntity.addReinforcement(entity);
}
}
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class Thunderstorm method doThunderstorm.
public static void doThunderstorm(EliteEntity eliteEntity) {
if (eliteEntity == null || !eliteEntity.getLivingEntity().isValid())
return;
eliteEntity.getLivingEntity().setAI(false);
new BukkitRunnable() {
int counter = 0;
@Override
public void run() {
counter++;
if (counter > 20 * 5 || eliteEntity == null || !eliteEntity.getLivingEntity().isValid()) {
cancel();
eliteEntity.getLivingEntity().setAI(true);
return;
}
if (counter % 2 == 0) {
Location randomLocation = eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(ThreadLocalRandom.current().nextInt(-20, 20), 0, ThreadLocalRandom.current().nextInt(-20, 20)));
lightningTask(randomLocation);
}
if (counter % 20 == 0) {
for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) if (entity.getType().equals(EntityType.PLAYER))
lightningTask(entity.getLocation());
}
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class EnderDragonEmpoweredLightning method fireLightning.
public void fireLightning(EliteEntity eliteEntity) {
doCooldown(eliteEntity);
for (Entity entity : eliteEntity.getLivingEntity().getLocation().getWorld().getNearbyEntities(eliteEntity.getLivingEntity().getLocation(), 150, 150, 150)) if (entity.getType().equals(EntityType.PLAYER))
lightningTask(entity.getLocation().clone());
for (int i = 0; i < 50; i++) {
Location randomLocation = locationRandomizer(eliteEntity.getLivingEntity().getLocation(), 0);
if (randomLocation == null)
continue;
new BukkitRunnable() {
@Override
public void run() {
lightningTask(randomLocation);
}
}.runTaskLater(MetadataHandler.PLUGIN, ThreadLocalRandom.current().nextInt(20 * 5));
}
}
Aggregations