Search in sources :

Example 1 with EnderCrystalLightningRod

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);
        }
    }
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity) NamespacedKey(org.bukkit.NamespacedKey) EnderCrystalLightningRod(com.magmaguy.elitemobs.powers.specialpowers.EnderCrystalLightningRod) Location(org.bukkit.Location)

Aggregations

EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)1 CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)1 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)1 EnderCrystalLightningRod (com.magmaguy.elitemobs.powers.specialpowers.EnderCrystalLightningRod)1 Location (org.bukkit.Location)1 NamespacedKey (org.bukkit.NamespacedKey)1