use of com.magmaguy.elitemobs.powers.meta.MinorPower in project EliteMobs by MagmaGuy.
the class EliteEntity method applyPowers.
public void applyPowers(HashSet<ElitePower> elitePowers, int availablePowerAmount) {
elitePowers.removeIf(elitePower -> !PowersConfig.getPower(elitePower.getFileName()).isEnabled());
if (availablePowerAmount < 1)
return;
ArrayList<ElitePower> localPowers = new ArrayList<>(elitePowers);
for (ElitePower mobPower : this.elitePowers) localPowers.remove(mobPower);
for (int i = 0; i < availablePowerAmount; i++) if (localPowers.size() < 1)
break;
else {
ElitePower selectedPower = localPowers.get(ThreadLocalRandom.current().nextInt(localPowers.size()));
try {
this.elitePowers.add(selectedPower.getClass().newInstance());
selectedPower.applyPowers(this.livingEntity);
localPowers.remove(selectedPower);
if (selectedPower instanceof MajorPower)
this.majorPowerCount++;
if (selectedPower instanceof MinorPower)
this.minorPowerCount++;
} catch (Exception ex) {
new WarningMessage("Failed to instance new power!");
}
}
}
Aggregations