Skip to content

Commit c1bf490

Browse files
committed
canMobMoveTowards
Can it move towards the target? If it cannot, it's stuck. Must be used as utility for another nerf check.
1 parent 28c0a3f commit c1bf490

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

src/main/java/adhdmc/nerffarms/listener/MobDamageListener.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,4 +358,14 @@ private boolean hasBlockedLineofSight(EntityDamageEvent event){
358358
return false;
359359
}
360360

361+
private boolean canMobMoveToward(Entity mob, Entity target) {
362+
if (!(mob instanceof Mob)) { return false; }
363+
Location targetLoc = target.getLocation();
364+
Pathfinder.PathResult entityPath = ((Mob) mob).getPathfinder().findPath(targetLoc);
365+
366+
if (entityPath == null) { return false; }
367+
368+
return (entityPath.getNextPoint() != null);
369+
}
370+
361371
}

0 commit comments

Comments
 (0)