Fixes event mobs getting stuck outside
This commit is contained in:
parent
639e089901
commit
c30d30b2e7
|
@ -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()
|
||||
|
@ -281,8 +283,27 @@ public abstract class EventCreature<T extends LivingEntity> implements Listener
|
|||
}
|
||||
|
||||
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));
|
||||
if (_teleportHome == -1)
|
||||
{
|
||||
_teleportHome = System.currentTimeMillis() + 5000;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_teleportHome != -1)
|
||||
{
|
||||
_teleportHome = -1;
|
||||
}
|
||||
}
|
||||
|
||||
_lastLocation = _entity.getLocation();
|
||||
|
|
Loading…
Reference in New Issue