Fixed sync with dragon and fixed guardian not showing

This commit is contained in:
LCastr0 2017-05-10 21:20:23 -03:00
parent 5fe5c613e5
commit ac0339fc59
3 changed files with 36 additions and 12 deletions

View File

@ -65,6 +65,32 @@ public class WinEffectRankEternal extends WinEffectRankBased
_step = 0;
}
@EventHandler
public void spawnGuardian(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
if (_guardian != null)
{
return;
}
if (!isRunning())
return;
_step++;
if (_step == 5)
{
Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation();
Manager.getPetManager().getCreatureModule().SetForce(true);
_guardian = npcLocation.getWorld().spawn(npcLocation, Guardian.class);
Manager.getPetManager().getCreatureModule().SetForce(false);
_step = 0;
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{
@ -74,22 +100,20 @@ public class WinEffectRankEternal extends WinEffectRankBased
if (event.getType() != UpdateType.FASTEST)
return;
if (_guardian == null)
{
return;
}
Location npcLocation = _npc.getEntity().getBukkitEntity().getLocation();
_step++;
if (_guardian == null)
{
Manager.getPetManager().getCreatureModule().SetForce(true);
_guardian = npcLocation.getWorld().spawn(npcLocation.add(0, 20, 0), Guardian.class);
Manager.getPetManager().getCreatureModule().SetForce(false);
}
double increment = (2 * Math.PI) / POINTS;
double angle = _step * increment;
Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS);
_guardian.setVelocity(new Vector(0,0,0));
_guardian.teleport(_player.getLocation().clone().subtract(vector));
_guardian.teleport(npcLocation.clone().subtract(vector));
Vector direction = npcLocation.toVector().subtract(_guardian.getEyeLocation().toVector());
Location enderLocation = _guardian.getLocation().setDirection(direction);
_guardian.teleport(enderLocation);

View File

@ -71,10 +71,10 @@ public class WinEffectRankHero extends WinEffectRankBased
if (!isRunning())
return;
if (_step > 65)
if (_step > 62)
return;
if (_step == 65)
if (_step == 62)
{
breakBlocks();
}
@ -100,7 +100,7 @@ public class WinEffectRankHero extends WinEffectRankBased
double angle = _step * increment;
Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS);
_enderDragon.setVelocity(new Vector(0, 0, 0));
_enderDragon.teleport(_player.getLocation().clone().subtract(vector));
_enderDragon.teleport(npcLocation.clone().subtract(vector));
Vector direction = npcLocation.toVector().subtract(_enderDragon.getEyeLocation().toVector()).multiply(-1);
Location enderLocation = _enderDragon.getLocation().setDirection(direction);
_enderDragon.teleport(enderLocation);

View File

@ -90,7 +90,7 @@ public class WinEffectRankLegend extends WinEffectRankBased
double angle = _step * increment;
Vector vector = new Vector(Math.cos(angle) * RADIUS, 0, Math.sin(angle) * RADIUS);
_wither.setVelocity(new Vector(0,0,0));
_wither.teleport(_player.getLocation().clone().subtract(vector));
_wither.teleport(npcLocation.clone().subtract(vector));
Vector direction = npcLocation.toVector().subtract(_wither.getEyeLocation().toVector());
Location enderLocation = _wither.getLocation().setDirection(direction);
_wither.teleport(enderLocation);