reorder code in TargetNearestPlayerOrMobGoal
mainly so that entities are not queried if the sentry is shut down
@@ -31,11 +31,12 @@ public class TargetNearestPlayerOrMobGoal extends NearestAttackableTargetGoal<Li
@Override
public boolean canUse() {
+ if (sentry.isShutDown())
+ return false;
+
List<LivingEntity> list = mob.level.<LivingEntity>getEntitiesOfClass(targetType, getTargetSearchArea(getFollowDistance()), e -> sentry.getSensing().hasLineOfSight(e) && !EntityUtils.isInvisible(e));
- if (list.isEmpty() || sentry.isShutDown())
- return false;
- else {
+ if (!list.isEmpty()) {
SentryMode mode = sentry.getMode();
int i;
@@ -79,10 +80,10 @@ public class TargetNearestPlayerOrMobGoal extends NearestAttackableTargetGoal<Li
return true;
}
}
+ }
return false;
}
- }
@Override
public boolean canContinueToUse() {
