use of com.magmaguy.elitemobs.utils.WarningMessage 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);
}
}
}
Aggregations