Skip to content

Commit a1b16ef

Browse files
committed
Fix goal removal again
1 parent 7e501e8 commit a1b16ef

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/com/solarrabbit/largeraids/versioned/nms/WorldServerWrapper.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public int clearMobTargets(Class<?> entityClass, AbstractBlockPositionWrapper se
3030
int count = 0;
3131
for (Mob mob : mobs)
3232
for (WrappedGoal goal : mob.goalSelector.getAvailableGoals()) {
33-
if (goal.getGoal().getClass() == PathfindToTargetGoal.class) {
33+
if (goal.getGoal() instanceof PathfindToTargetGoal) {
3434
mob.goalSelector.removeGoal(goal.getGoal());
3535
count++;
3636
break;
@@ -51,7 +51,12 @@ public int setMobTargets(Class<?> entityClass, AbstractBlockPositionWrapper sear
5151
searchPos.getX() + range, searchPos.getY() + range, searchPos.getZ() + range);
5252
List<? extends Mob> mobs = server.getEntitiesOfClass((Class<? extends Mob>) entityClass, aabb);
5353
for (Mob mob : mobs) {
54-
mob.goalSelector.getAvailableGoals().removeIf(goal -> goal.getGoal() instanceof PathfindToTargetGoal);
54+
for (WrappedGoal goal : mob.goalSelector.getAvailableGoals()) {
55+
if (goal.getGoal() instanceof PathfindToTargetGoal) {
56+
mob.goalSelector.removeGoal(goal.getGoal());
57+
break;
58+
}
59+
}
5560

5661
PathfindToTargetGoal goal = new PathfindToTargetGoal(mob);
5762
goal.setTargetPos(((BlockPositionWrapper) target).blockPos, radius, navSpeed, pathfindOnce);

0 commit comments

Comments
 (0)