use of com.magmaguy.elitemobs.powers.specialpowers.EnderCrystalLightningRod 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);
}
}
}
Aggregations