Search in sources :

Example 1 with EnderDragon

use of org.bukkit.entity.EnderDragon in project TotalFreedomMod by TotalFreedom.

the class Command_mobpurge method purgeMobs.

public static int purgeMobs() {
    int removed = 0;
    for (World world : Bukkit.getWorlds()) {
        for (Entity ent : world.getLivingEntities()) {
            if (ent instanceof Creature || ent instanceof Ghast || ent instanceof Slime || ent instanceof EnderDragon || ent instanceof Ambient) {
                ent.remove();
                removed++;
            }
        }
    }
    return removed;
}
Also used : Entity(org.bukkit.entity.Entity) Creature(org.bukkit.entity.Creature) EnderDragon(org.bukkit.entity.EnderDragon) Ambient(org.bukkit.entity.Ambient) Ghast(org.bukkit.entity.Ghast) World(org.bukkit.World) Slime(org.bukkit.entity.Slime)

Example 2 with EnderDragon

use of org.bukkit.entity.EnderDragon in project Citizens2 by CitizensDev.

the class Controllable method setMountedYaw.

private void setMountedYaw(Entity entity) {
    if (entity instanceof EnderDragon || !Setting.USE_BOAT_CONTROLS.asBoolean())
        // EnderDragon handles this separately
        return;
    Location loc = entity.getLocation();
    Vector vel = entity.getVelocity();
    if (vel.lengthSquared() == 0) {
        return;
    }
    double tX = loc.getX() + vel.getX();
    double tZ = loc.getZ() + vel.getZ();
    if (loc.getZ() > tZ) {
        loc.setYaw((float) -Math.toDegrees(Math.atan((loc.getX() - tX) / (loc.getZ() - tZ))) + 180F);
    } else if (loc.getZ() < tZ) {
        loc.setYaw((float) -Math.toDegrees(Math.atan((loc.getX() - tX) / (loc.getZ() - tZ))));
    }
    NMS.look(entity, loc.getYaw(), loc.getPitch());
}
Also used : EnderDragon(org.bukkit.entity.EnderDragon) Vector(org.bukkit.util.Vector) Location(org.bukkit.Location)

Example 3 with EnderDragon

use of org.bukkit.entity.EnderDragon in project EliteMobs by MagmaGuy.

the class EnderDragonTornado method doPower.

private void doPower(EliteEntity eliteEntity) {
    doCooldown(eliteEntity);
    tornadoEye = eliteEntity.getLivingEntity().getLocation().clone().add(new Vector(6, -6, 0)).toVector().rotateAroundY(ThreadLocalRandom.current().nextDouble(0, 2 * Math.PI)).toLocation(eliteEntity.getLivingEntity().getWorld());
    tornadoSpeed = tornadoEye.clone().subtract(eliteEntity.getLivingEntity().getLocation()).toVector().setY(0).normalize().multiply(0.2);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (!eliteEntity.isValid()) {
                cancel();
                return;
            }
            if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON))
                ((EnderDragon) eliteEntity.getLivingEntity()).setPhase(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET);
            if (doExit(eliteEntity) || eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON) && !EnderDragonPhaseSimplifier.isLanded(((EnderDragon) eliteEntity.getLivingEntity()).getPhase())) {
                cancel();
                return;
            }
            tornadoEye.add(tornadoSpeed);
            if (counter % 2 == 0) {
                doTornadoParticles();
                doTerrainDestruction(eliteEntity);
                doEntityDisplacement(eliteEntity.getLivingEntity());
            }
            if (counter > 20 * 6) {
                cancel();
            }
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : EnderDragon(org.bukkit.entity.EnderDragon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) Vector(org.bukkit.util.Vector)

Example 4 with EnderDragon

use of org.bukkit.entity.EnderDragon in project EliteMobs by MagmaGuy.

the class Bombardment method activate.

public void activate(EliteEntity eliteEntity) {
    if (isActive)
        return;
    isActive = true;
    task = new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            counter++;
            if (stopCondition(eliteEntity))
                return;
            if (firing || isInCooldown(eliteEntity))
                return;
            if (ThreadLocalRandom.current().nextDouble() > 0.1)
                return;
            if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON)) {
                EnderDragon.Phase phase = ((EnderDragon) eliteEntity.getLivingEntity()).getPhase();
                if (phase.equals(EnderDragon.Phase.DYING) || phase.equals(EnderDragon.Phase.HOVER) || phase.equals(EnderDragon.Phase.ROAR_BEFORE_ATTACK) || phase.equals(EnderDragon.Phase.FLY_TO_PORTAL) || phase.equals(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET)) {
                    return;
                }
            }
            for (Entity entity : eliteEntity.getLivingEntity().getNearbyEntities(10, 100, 10)) {
                if (entity.getType().equals(EntityType.PLAYER)) {
                    firing = true;
                    fire(eliteEntity);
                    return;
                }
            }
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 5);
}
Also used : Entity(org.bukkit.entity.Entity) EliteEntity(com.magmaguy.elitemobs.mobconstructor.EliteEntity) EnderDragon(org.bukkit.entity.EnderDragon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Example 5 with EnderDragon

use of org.bukkit.entity.EnderDragon in project EliteMobs by MagmaGuy.

the class EnderDragonDiscoFireballs method doPower.

private void doPower(EliteEntity eliteEntity) {
    doCooldown(eliteEntity);
    new BukkitRunnable() {

        int counter = 0;

        @Override
        public void run() {
            if (doExit(eliteEntity) || eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON) && !EnderDragonPhaseSimplifier.isLanded(((EnderDragon) eliteEntity.getLivingEntity()).getPhase())) {
                cancel();
                return;
            }
            if (eliteEntity.getLivingEntity().getType().equals(EntityType.ENDER_DRAGON))
                ((EnderDragon) eliteEntity.getLivingEntity()).setPhase(EnderDragon.Phase.SEARCH_FOR_BREATH_ATTACK_TARGET);
            if (counter == 0) {
                // todo: reset fields if needed
                generateLocations();
                commitLocations(eliteEntity);
                randomTiltSeed = ThreadLocalRandom.current().nextInt();
                warningCounter = 0;
            }
            if (counter < 20 * 6) {
                // todo: warning phase
                doWarningPhase(eliteEntity);
                warningCounter++;
            }
            if (counter > 20 * 6) {
                doDamagePhase(eliteEntity);
                cancel();
            }
            counter++;
        }
    }.runTaskTimer(MetadataHandler.PLUGIN, 0, 1);
}
Also used : EnderDragon(org.bukkit.entity.EnderDragon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

Aggregations

EnderDragon (org.bukkit.entity.EnderDragon)8 Entity (org.bukkit.entity.Entity)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3 Location (org.bukkit.Location)2 Ghast (org.bukkit.entity.Ghast)2 Slime (org.bukkit.entity.Slime)2 EventHandler (org.bukkit.event.EventHandler)2 Vector (org.bukkit.util.Vector)2 EliteEntity (com.magmaguy.elitemobs.mobconstructor.EliteEntity)1 World (org.bukkit.World)1 Ambient (org.bukkit.entity.Ambient)1 Animals (org.bukkit.entity.Animals)1 Bat (org.bukkit.entity.Bat)1 Creature (org.bukkit.entity.Creature)1 Giant (org.bukkit.entity.Giant)1 HumanEntity (org.bukkit.entity.HumanEntity)1 LivingEntity (org.bukkit.entity.LivingEntity)1 Monster (org.bukkit.entity.Monster)1 Projectile (org.bukkit.entity.Projectile)1 Tameable (org.bukkit.entity.Tameable)1