Prevent entities from moving during death animation

This commit is contained in:
themode 2021-01-28 15:37:55 +01:00
parent 522b4edc7a
commit fa0c5050e4
2 changed files with 7 additions and 2 deletions

View File

@ -78,7 +78,7 @@ public abstract class EntityCreature extends LivingEntity implements NavigableEn
aiTick(time);
// Path finding
this.navigator.pathFindingTick(getAttributeValue(Attributes.MOVEMENT_SPEED));
this.navigator.tick(getAttributeValue(Attributes.MOVEMENT_SPEED));
// Fire, item pickup, ...
super.update(time);

View File

@ -4,6 +4,7 @@ import com.extollit.gaming.ai.path.HydrazinePathFinder;
import com.extollit.gaming.ai.path.model.IPath;
import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.LivingEntity;
import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.WorldBorder;
@ -159,7 +160,11 @@ public class Navigator {
return setPathTo(position, true);
}
public synchronized void pathFindingTick(float speed) {
public synchronized void tick(float speed) {
// No pathfinding tick for dead entities
if (entity instanceof LivingEntity && ((LivingEntity) entity).isDead())
return;
if (pathPosition != null) {
IPath path = pathFinder.updatePathFor(pathingEntity);