fix behavior when all have been mined

This commit is contained in:
Leijurv 2018-09-01 12:16:55 -07:00
parent e354227635
commit aca487f97e
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -55,11 +55,6 @@ public class MineBehavior extends Behavior {
return;
}
List<BlockPos> locs = new ArrayList<>(WorldProvider.INSTANCE.getCurrentWorld().cache.getLocationsOf(mining, 1, 1));
if (locs.isEmpty()) {
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
cancel();
return;
}
BlockPos playerFeet = playerFeet();
locs.sort(Comparator.comparingDouble(playerFeet::distanceSq));
@ -71,6 +66,11 @@ public class MineBehavior extends Behavior {
if (locs.size() > 30) {
locs = locs.subList(0, 30);
}
if (locs.isEmpty()) {
displayChatMessageRaw("No locations for " + mining + " known, cancelling");
cancel();
return;
}
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalTwoBlocks::new).toArray(Goal[]::new)));
PathingBehavior.INSTANCE.path();
}