Fixes event mobs getting stuck outside

This commit is contained in:
AlexTheCoder 2016-07-28 05:33:37 -04:00
parent 639e089901
commit c30d30b2e7
1 changed files with 22 additions and 1 deletions

View File

@ -37,6 +37,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
private double _health;
private double _maxHealth;
private boolean _showHealthName;
private long _teleportHome;
// Fight Data
private long _lastDamaged;
@ -55,6 +56,7 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
_health = health;
_maxHealth = health;
_showHealthName = true;
_teleportHome = -1L;
}
public double getDifficulty()
@ -282,7 +284,26 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
if (UtilMath.offset2d(_entity.getLocation(), _spawnLocation) > 34)
{
_entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2));
if (_teleportHome != -1 && System.currentTimeMillis() >= _teleportHome)
{
_entity.teleport(_spawnLocation);
_teleportHome = -1;
}
else
{
_entity.setVelocity(UtilAlg.getTrajectory(_entity.getLocation(), _spawnLocation).normalize().multiply(2));
if (_teleportHome == -1)
{
_teleportHome = System.currentTimeMillis() + 5000;
}
}
}
else
{
if (_teleportHome != -1)
{
_teleportHome = -1;
}
}
_lastLocation = _entity.getLocation();