Search in sources :

Example 21 with CustomBossEntity

use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.

the class CustomSummonPower method summonReinforcement.

private void summonReinforcement(EliteEntity eliteEntity, CustomBossReinforcement customBossReinforcement) {
    if (customBossReinforcement.summonChance != null && ThreadLocalRandom.current().nextDouble() > customBossReinforcement.summonChance)
        return;
    for (int i = 0; i < customBossReinforcement.amount; i++) {
        Location spawnLocation = eliteEntity.getLocation();
        if (customBossReinforcement.spawnLocationOffset != null)
            spawnLocation = getFinalSpawnLocation(eliteEntity, customBossReinforcement.spawnLocationOffset);
        if (customBossReinforcement.spawnNearby)
            for (int loc = 0; loc < 30; loc++) {
                Location randomLocation = spawnLocation.clone().add(new Vector(ThreadLocalRandom.current().nextInt(-15, 15), 0, ThreadLocalRandom.current().nextInt(-15, 15)));
                randomLocation.setY(CustomSpawn.getHighestValidBlock(randomLocation, 256));
                if (randomLocation.getY() == -100)
                    continue;
                spawnLocation = randomLocation;
                break;
            }
        if (CustomBossesConfig.getCustomBoss(customBossReinforcement.bossFileName).isRegionalBoss()) {
            RegionalBossEntity regionalBossEntity = RegionalBossEntity.createTemporaryRegionalBossEntity(customBossReinforcement.bossFileName, spawnLocation);
            if (regionalBossEntity == null) {
                new WarningMessage("Failed to spawn reinforcement for " + eliteEntity.getName() + " because boss " + customBossReinforcement.bossFileName + " was invalid! Does the file exist? Is it configured correctly?");
                return;
            }
            if (customBossReinforcement.inheritLevel)
                regionalBossEntity.setLevel(eliteEntity.getLevel());
            if (!customBossReinforcement.summonType.equals(SummonType.ON_DEATH))
                eliteEntity.addReinforcement(regionalBossEntity);
            customBossReinforcement.isSummoned = true;
            regionalBossEntity.setSummoningEntity(eliteEntity);
            regionalBossEntity.initialize();
        } else {
            CustomBossEntity customBossEntity = CustomBossEntity.createCustomBossEntity(customBossReinforcement.bossFileName);
            if (customBossEntity == null) {
                new WarningMessage("Failed to spawn reinforcement for " + eliteEntity.getName() + " because boss " + customBossReinforcement.bossFileName + " was invalid! Does the file exist? Is it configured correctly?");
                return;
            }
            customBossEntity.setSpawnLocation(spawnLocation);
            customBossEntity.setBypassesProtections(eliteEntity.getBypassesProtections());
            if (customBossReinforcement.inheritLevel)
                customBossEntity.setLevel(eliteEntity.getLevel());
            customBossEntity.spawn(false);
            if (customBossEntity.getLivingEntity() != null)
                customBossEntity.getLivingEntity().setVelocity(new Vector(ThreadLocalRandom.current().nextDouble(0.2), 0.2, ThreadLocalRandom.current().nextDouble(0.2)));
            if (!customBossReinforcement.summonType.equals(SummonType.ON_DEATH))
                eliteEntity.addReinforcement(customBossEntity);
            customBossReinforcement.isSummoned = true;
            customBossEntity.setSummoningEntity(eliteEntity);
        }
    }
}
Also used : WarningMessage(com.magmaguy.elitemobs.utils.WarningMessage) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) Vector(org.bukkit.util.Vector) RegionalBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity) Location(org.bukkit.Location)

Example 22 with CustomBossEntity

use of com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity in project EliteMobs by MagmaGuy.

the class WorldGuardDungeonFlag method onSpawn.

@EventHandler(ignoreCancelled = true)
public void onSpawn(CreatureSpawnEvent event) {
    if (!EliteMobs.worldGuardIsEnabled)
        return;
    if (event.getEntity().getType().equals(EntityType.ARMOR_STAND) || event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.CUSTOM))
        return;
    if (WorldGuardFlagChecker.checkFlag(event.getLocation(), WorldGuardCompatibility.getEliteMobsDungeonFlag())) {
        EliteEntity eliteEntity = EntityTracker.getEliteMobEntity(event.getEntity());
        if (eliteEntity instanceof CustomBossEntity)
            return;
        event.setCancelled(true);
        event.getEntity().remove();
    }
}
Also used : EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) CustomBossEntity(com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

CustomBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.CustomBossEntity)22 WarningMessage (com.magmaguy.elitemobs.utils.WarningMessage)9 CustomBossesConfigFields (com.magmaguy.elitemobs.config.custombosses.CustomBossesConfigFields)5 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)5 Location (org.bukkit.Location)5 EventHandler (org.bukkit.event.EventHandler)5 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)5 Vector (org.bukkit.util.Vector)5 RegionalBossEntity (com.magmaguy.elitemobs.mobconstructor.custombosses.RegionalBossEntity)3 ArrayList (java.util.ArrayList)3 Entity (org.bukkit.entity.Entity)3 LivingEntity (org.bukkit.entity.LivingEntity)3 MetadataHandler (com.magmaguy.elitemobs.MetadataHandler)2 HashMap (java.util.HashMap)2 List (java.util.List)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 Player (org.bukkit.entity.Player)2 Wolf (org.bukkit.entity.Wolf)2 PotionEffect (org.bukkit.potion.PotionEffect)2