Fixes event mobs getting stuck outside

This commit is contained in:
AlexTheCoder 2016-07-28 05:33:37 -04:00
parent 639e089901
commit c30d30b2e7

View File

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