use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class SpiritWalk method spiritWalkRegionalBossAnimation.
public static void spiritWalkRegionalBossAnimation(EliteEntity eliteEntity, Location entityLocation, Location finalLocation) {
eliteEntity.getLivingEntity().setAI(false);
eliteEntity.getLivingEntity().setInvulnerable(true);
Vector toDestination = finalLocation.clone().subtract(entityLocation.clone()).toVector().normalize().divide(new Vector(2, 2, 2));
Entity vehicle = null;
if (eliteEntity.getLivingEntity().isInsideVehicle()) {
vehicle = eliteEntity.getLivingEntity().getVehicle();
if (vehicle instanceof LivingEntity)
((LivingEntity) vehicle).setAI(false);
vehicle.setInvulnerable(true);
if (((CustomBossEntity) eliteEntity).getPhaseBossEntity() != null)
vehicle.remove();
}
new BukkitRunnable() {
final Entity vehicle = eliteEntity.getLivingEntity().getVehicle();
int counter = 0;
@Override
public void run() {
if (!eliteEntity.isValid()) {
cancel();
return;
}
if (eliteEntity.getLivingEntity().isInsideVehicle())
eliteEntity.getLivingEntity().leaveVehicle();
if (eliteEntity.getLivingEntity().getLocation().clone().distance(finalLocation) < 2 || counter > 20 * 10) {
eliteEntity.getLivingEntity().setAI(true);
eliteEntity.getLivingEntity().setInvulnerable(false);
if (vehicle != null && !vehicle.isDead())
vehicle.teleport(finalLocation);
eliteEntity.getLivingEntity().teleport(finalLocation);
if (vehicle != null && !vehicle.isDead()) {
if (vehicle instanceof LivingEntity) {
((LivingEntity) vehicle).setAI(true);
EliteEntity vehicleBoss = EntityTracker.getEliteMobEntity(vehicle);
if (vehicleBoss != null)
Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(vehicleBoss, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
}
vehicle.setInvulnerable(false);
new BukkitRunnable() {
@Override
public void run() {
PreventMountExploit.bypass = true;
vehicle.addPassenger(eliteEntity.getLivingEntity());
}
}.runTaskLater(MetadataHandler.PLUGIN, 1);
}
cancel();
Bukkit.getServer().getPluginManager().callEvent(new EliteMobExitCombatEvent(eliteEntity, EliteMobExitCombatEvent.EliteMobExitCombatReason.SPIRIT_WALK));
if (eliteEntity.getLivingEntity() instanceof Mob)
if (((Mob) eliteEntity.getLivingEntity()).getTarget() == null)
eliteEntity.getLivingEntity().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.MAX_VALUE, 2));
}
if (vehicle != null && !vehicle.isDead()) {
vehicle.teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
}
eliteEntity.getLivingEntity().teleport(eliteEntity.getLivingEntity().getLocation().clone().add(toDestination.clone()));
counter++;
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class NaturalMobSpawnEventHandler method onSpawn.
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onSpawn(CreatureSpawnEvent event) {
if (event.getSpawnReason().equals(DROWNED))
return;
if (!VersionChecker.serverVersionOlderThan(15, 0))
if (event.getEntity().getType().equals(EntityType.BEE))
return;
if (MobPropertiesConfig.getMobProperties().get(event.getEntityType()) == null || !MobPropertiesConfig.getMobProperties().get(event.getEntityType()).isEnabled())
return;
if (EliteMobs.worldGuardIsEnabled)
if (!WorldGuardFlagChecker.checkFlag(event.getLocation(), WorldGuardCompatibility.getEliteMobsSpawnFlag()))
return;
// This fires for custom bosses, so don't override those spawns
if (WorldGuardSpawnEventBypasser.isForcedSpawn())
return;
/*
Deal with entities spawned within the plugin
*/
if (EntityTracker.isEliteMob(event.getEntity()))
return;
if (!MobCombatSettingsConfig.isDoNaturalMobSpawning())
return;
if (!ValidWorldsConfig.getFileConfiguration().getBoolean("Valid worlds." + event.getEntity().getWorld().getName()))
return;
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER) && !MobCombatSettingsConfig.isDoSpawnersSpawnEliteMobs() || event.getSpawnReason() == CUSTOM && DefaultConfig.isDoStrictSpawningRules())
return;
if (event.getEntity().getCustomName() != null && DefaultConfig.isPreventEliteMobConversionOfNamedMobs())
return;
if (!EliteMobProperties.isValidEliteMobType(event.getEntityType()))
return;
LivingEntity livingEntity = event.getEntity();
double validChance = MobCombatSettingsConfig.getAggressiveMobConversionPercentage();
List<Player> nearbyPlayers = PlayerScanner.getNearbyPlayers(livingEntity.getLocation());
double huntingGearChanceAdder = HunterEnchantment.getHuntingGearBonus(nearbyPlayers);
validChance += huntingGearChanceAdder;
if (ValidWorldsConfig.getNightmareWorlds().contains(event.getEntity().getWorld().getName()))
validChance += DefaultConfig.getNightmareWorldSpawnBonus();
if (ThreadLocalRandom.current().nextDouble() >= validChance)
return;
if (ValidWorldsConfig.getZoneBasedWorlds().contains(livingEntity.getWorld().getName())) {
int eliteMobLevel = (int) (Grid.getMobTierFromLocation(livingEntity.getLocation()));
EliteEntity eliteEntity = new EliteEntity(livingEntity, eliteMobLevel, event.getSpawnReason());
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER))
eliteEntity.setEliteLoot(false);
return;
}
int eliteMobLevel = getNaturalMobLevel(livingEntity.getLocation(), nearbyPlayers);
// Takes worldguard minimum and maximum level flags into account
if (EliteMobs.worldGuardIsEnabled) {
Integer minLevel = WorldGuardFlagChecker.getRegionMinimumLevel(livingEntity.getLocation());
Integer maxLevel = WorldGuardFlagChecker.getRegionMaximumLevel(livingEntity.getLocation());
if (minLevel != null)
eliteMobLevel = minLevel > eliteMobLevel ? minLevel : eliteMobLevel;
if (maxLevel != null)
eliteMobLevel = maxLevel < eliteMobLevel ? maxLevel : eliteMobLevel;
}
if (eliteMobLevel < 0)
return;
if (eliteMobLevel > MobCombatSettingsConfig.getNaturalEliteMobLevelCap())
eliteMobLevel = MobCombatSettingsConfig.getNaturalEliteMobLevelCap();
EliteEntity eliteEntity = new EliteEntity(livingEntity, eliteMobLevel, event.getSpawnReason());
if (event.getSpawnReason().equals(CreatureSpawnEvent.SpawnReason.SPAWNER))
eliteEntity.setEliteLoot(false);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class BulletHell method doBulletHell.
public void doBulletHell(EliteEntity eliteEntity) {
eliteEntity.getLivingEntity().setAI(false);
if (eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 10, 0)).getBlock().getType().equals(Material.AIR))
eliteEntity.getLivingEntity().teleport(eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 10, 0)));
new BukkitRunnable() {
final Location initialLocation = eliteEntity.getLivingEntity().getLocation().clone();
int counter = 0;
@Override
public void run() {
if (!eliteEntity.isValid()) {
cancel();
return;
}
eliteEntity.getLivingEntity().getWorld().spawnParticle(Particle.DRIP_WATER, eliteEntity.getLivingEntity().getLocation(), 10, 1, 1, 1);
for (Entity nearbyEntity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) if (nearbyEntity instanceof Player && (((Player) nearbyEntity).getGameMode().equals(GameMode.ADVENTURE) || ((Player) nearbyEntity).getGameMode().equals(GameMode.SURVIVAL))) {
Arrow arrow = (Arrow) EliteProjectile.create(EntityType.ARROW, eliteEntity.getLivingEntity(), (Player) nearbyEntity, false);
arrow.setVelocity(arrow.getVelocity().multiply(0.1));
trackingArrowLoop((Player) nearbyEntity, arrow);
}
counter++;
if (counter > 20) {
cancel();
eliteEntity.getLivingEntity().setAI(true);
eliteEntity.getLivingEntity().teleport(initialLocation);
}
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 10);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class FireworksBarrage method doFireworksBarrage.
public void doFireworksBarrage(EliteEntity eliteEntity) {
eliteEntity.getLivingEntity().setAI(false);
if (eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 10, 0)).getBlock().getType().equals(Material.AIR))
if (!eliteEntity.getLivingEntity().getType().equals(EntityType.GHAST))
eliteEntity.getLivingEntity().teleport(eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(0, 10, 0)));
FireworksBarrage fireworksBarrage = this;
new BukkitRunnable() {
final Location initialLocation = eliteEntity.getLivingEntity().getLocation().clone();
int counter = 0;
@Override
public void run() {
if (!eliteEntity.isValid()) {
cancel();
return;
}
for (int i = 0; i < 2; i++) {
Firework firework = (Firework) eliteEntity.getLivingEntity().getWorld().spawnEntity(eliteEntity.getLivingEntity().getLocation(), EntityType.FIREWORK);
FireworkMeta fireworkMeta = firework.getFireworkMeta();
fireworkMeta.setPower(10);
fireworkMeta.addEffect(FireworkEffect.builder().withColor(Color.RED, Color.WHITE, Color.BLUE).flicker(true).build());
firework.setFireworkMeta(fireworkMeta);
firework.setVelocity(new Vector(ThreadLocalRandom.current().nextDouble(-0.5, 0.5), ThreadLocalRandom.current().nextDouble(), ThreadLocalRandom.current().nextDouble(-0.5, 0.5)));
}
for (Entity nearbyEntity : eliteEntity.getLivingEntity().getNearbyEntities(20, 20, 20)) if (nearbyEntity instanceof Player)
if (((Player) nearbyEntity).getGameMode().equals(GameMode.ADVENTURE) || ((Player) nearbyEntity).getGameMode().equals(GameMode.SURVIVAL)) {
Firework firework = (Firework) eliteEntity.getLivingEntity().getWorld().spawnEntity(eliteEntity.getLivingEntity().getLocation(), EntityType.FIREWORK);
FireworkMeta fireworkMeta = firework.getFireworkMeta();
fireworkMeta.setPower(10);
fireworkMeta.addEffect(FireworkEffect.builder().withColor(Color.RED, Color.WHITE, Color.BLUE).flicker(true).build());
firework.setFireworkMeta(fireworkMeta);
firework.setVelocity(((Player) nearbyEntity).getEyeLocation().clone().subtract(firework.getLocation()).toVector().normalize().multiply(0.5));
firework.setShotAtAngle(true);
new FireworkTask(firework, nearbyEntity.getLocation().clone(), eliteEntity, fireworksBarrage);
}
counter++;
if (counter > 10) {
cancel();
eliteEntity.getLivingEntity().setAI(true);
eliteEntity.getLivingEntity().teleport(initialLocation);
}
}
}.runTaskTimer(MetadataHandler.PLUGIN, 0, 10);
}
use of com.magmaguy.elitemobs.mobconstructor.EliteEntity in project EliteMobs by MagmaGuy.
the class EnderDragonShockwave method doDamagePhase.
private void doDamagePhase(EliteEntity eliteEntity) {
List<Block> blockList = new ArrayList<>();
Iterator<PieBlock> pieBlockIterator = realBlocks.iterator();
while (pieBlockIterator.hasNext()) {
PieBlock pieBlock = pieBlockIterator.next();
if (pieBlock.distance < damagePhaseCounter) {
Location rawPieBlock = eliteEntity.getLivingEntity().getLocation().clone().add(pieBlock.vector);
if (rawPieBlock.getBlock().isPassable())
continue;
for (Entity entity : rawPieBlock.getWorld().getNearbyEntities(new BoundingBox(rawPieBlock.getX(), rawPieBlock.getY(), rawPieBlock.getZ(), rawPieBlock.getX() + 1, rawPieBlock.getY() + 3, rawPieBlock.getZ() + 1))) {
if (entity.getType().equals(EntityType.FALLING_BLOCK))
continue;
entity.setVelocity(entity.getLocation().clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().setY(1).normalize().multiply(3));
if (entity.getType().equals(EntityType.PLAYER))
BossCustomAttackDamage.dealCustomDamage(eliteEntity.getLivingEntity(), (LivingEntity) entity, 20);
}
if (rawPieBlock.getBlock().getType().getBlastResistance() >= 7)
continue;
blockList.add(rawPieBlock.getBlock());
pieBlockIterator.remove();
}
}
damagePhaseCounter++;
Explosion.generateFakeExplosion(blockList, eliteEntity.getLivingEntity());
}
Aggregations