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;
}
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());
}
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);
}
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);
}
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);
}
Aggregations