Attempt to fix the fireballs fired by ghasts

This commit is contained in:
Sam 2017-12-04 00:47:18 +00:00 committed by Alexander Meech
parent e610d7f1ea
commit 0b08e6052d
4 changed files with 42 additions and 7 deletions

View File

@ -136,7 +136,7 @@ public class ChristmasNew extends ChristmasCommon
int blockId = Material.STAINED_CLAY.getId(); int blockId = Material.STAINED_CLAY.getId();
TextAlign align = TextAlign.CENTER; TextAlign align = TextAlign.CENTER;
UtilBlockText.MakeText("Happy Holidays", location, face, blockId, (byte) 14, align); UtilBlockText.MakeText("Merry Christmas", location, face, blockId, (byte) 14, align);
UtilBlockText.MakeText("from", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 5, align); UtilBlockText.MakeText("from", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 5, align);
UtilBlockText.MakeText("Mineplex", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 4, align); UtilBlockText.MakeText("Mineplex", location.subtract(0, 6, 0), BlockFace.WEST, blockId, (byte) 4, align);

View File

@ -10,12 +10,16 @@ import org.bukkit.entity.Blaze;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Creeper; import org.bukkit.entity.Creeper;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Ghast; import org.bukkit.entity.Ghast;
import org.bukkit.entity.LargeFireball;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.PigZombie; import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ProjectileHitEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
@ -50,6 +54,7 @@ class MobDefense extends SectionChallenge
private int _generatorHealth; private int _generatorHealth;
private int _wave; private int _wave;
private Ghast _ghast;
MobDefense(ChristmasNew host, Location present, Section section, List<Location> mobSpawns, Location ghastSpawn, Location generator, List<Location> healthIndicators, List<Location> particles) MobDefense(ChristmasNew host, Location present, Section section, List<Location> mobSpawns, Location ghastSpawn, Location generator, List<Location> healthIndicators, List<Location> particles)
{ {
@ -63,7 +68,7 @@ class MobDefense extends SectionChallenge
_particles = particles; _particles = particles;
_generatorHealth = GENERATOR_HEALTH; _generatorHealth = GENERATOR_HEALTH;
_ghastSpawn.setYaw(UtilAlg.GetYaw(UtilAlg.getTrajectory2d(ghastSpawn, generator))); _ghastSpawn.setYaw(180);
} }
@Override @Override
@ -181,6 +186,36 @@ class MobDefense extends SectionChallenge
} }
} }
@EventHandler
public void updateGhastFire(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW || _ghast == null || !_ghast.isValid())
{
return;
}
Location location = _ghast.getLocation().add(0, 0.5, 0);
Fireball fireball = _ghast.launchProjectile(LargeFireball.class);
fireball.setBounce(false);
fireball.setDirection(UtilAlg.getTrajectory(location, _generator).multiply(0.5));
}
@EventHandler
public void projectileHit(ProjectileHitEvent event)
{
if (_ghast == null)
{
return;
}
Projectile projectile = event.getEntity();
if (projectile instanceof LargeFireball && UtilMath.offsetSquared(projectile.getLocation(), _generator) < 25)
{
_generatorHealth -= 5;
}
}
@EventHandler @EventHandler
public void updateHolograms(UpdateEvent event) public void updateHolograms(UpdateEvent event)
{ {
@ -193,7 +228,7 @@ class MobDefense extends SectionChallenge
_healthHolograms.forEach(hologram -> hologram.setText(text)); _healthHolograms.forEach(hologram -> hologram.setText(text));
_particles.forEach(location -> UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location,null, 0.1F, _wave, ViewDist.NORMAL)); _particles.forEach(location -> UtilParticle.PlayParticleToAll(ParticleType.FIREWORKS_SPARK, location, null, 0.1F, _wave, ViewDist.NORMAL));
} }
private void spawnMob(Class<? extends Entity> clazz, int amount, int players) private void spawnMob(Class<? extends Entity> clazz, int amount, int players)
@ -209,9 +244,9 @@ class MobDefense extends SectionChallenge
public void spawnGhast() public void spawnGhast()
{ {
Ghast ghast = spawn(_ghastSpawn, Ghast.class); _ghast = spawn(_ghastSpawn, Ghast.class);
UtilEnt.vegetate(ghast); UtilEnt.vegetate(_ghast);
} }
public void setWave(int wave) public void setWave(int wave)

View File

@ -80,7 +80,7 @@ public class Section4 extends Section
@EventHandler @EventHandler
public void updateWaves(UpdateEvent event) public void updateWaves(UpdateEvent event)
{ {
if (event.getType() != UpdateType.SEC || _start == 0) if (event.getType() != UpdateType.SEC || _start == 0 || !_host.IsLive())
{ {
return; return;
} }

View File

@ -37,7 +37,7 @@ class BossFight extends SectionChallenge
{ {
private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN); private static final ItemStack HELMET = new ItemStack(Material.PUMPKIN);
private static final int TIME_OF_DAY = 11000; private static final int TIME_OF_DAY = 12000;
private final Location _bossSpawn; private final Location _bossSpawn;
private final List<Location> _lightning; private final List<Location> _lightning;