demolish goto, fixes #182
This commit is contained in:
parent
8ee7446517
commit
6829bc920e
@ -383,29 +383,35 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
|
|||||||
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
waypointType = waypointType.substring(0, waypointType.length() - 1);
|
||||||
}
|
}
|
||||||
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
Waypoint.Tag tag = Waypoint.Tag.fromString(waypointType);
|
||||||
|
IWaypoint waypoint;
|
||||||
if (tag == null) {
|
if (tag == null) {
|
||||||
String mining = waypointType;
|
String mining = waypointType;
|
||||||
Block block = ChunkPacker.stringToBlock(mining);
|
Block block = ChunkPacker.stringToBlock(mining);
|
||||||
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
//logDirect("Not a valid tag. Tags are: " + Arrays.asList(Waypoint.Tag.values()).toString().toLowerCase());
|
||||||
event.cancel();
|
event.cancel();
|
||||||
if (block == null) {
|
if (block == null) {
|
||||||
logDirect("No locations for " + mining + " known, cancelling");
|
waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getAllWaypoints().stream().filter(w -> w.getName().equalsIgnoreCase(mining)).max(Comparator.comparingLong(IWaypoint::getCreationTimestamp)).orElse(null);
|
||||||
|
if (waypoint == null) {
|
||||||
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<BlockPos> locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64);
|
||||||
|
if (locs.isEmpty()) {
|
||||||
|
logDirect("No locations for " + mining + " known, cancelling");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new)));
|
||||||
|
PathingBehavior.INSTANCE.path();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<BlockPos> locs = MineBehavior.INSTANCE.scanFor(Collections.singletonList(block), 64);
|
} else {
|
||||||
if (locs.isEmpty()) {
|
waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag);
|
||||||
logDirect("No locations for " + mining + " known, cancelling");
|
if (waypoint == null) {
|
||||||
|
logDirect("None saved for tag " + tag);
|
||||||
|
event.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PathingBehavior.INSTANCE.setGoal(new GoalComposite(locs.stream().map(GoalGetToBlock::new).toArray(Goal[]::new)));
|
|
||||||
PathingBehavior.INSTANCE.path();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IWaypoint waypoint = WorldProvider.INSTANCE.getCurrentWorld().getWaypoints().getMostRecentByTag(tag);
|
|
||||||
if (waypoint == null) {
|
|
||||||
logDirect("None saved for tag " + tag);
|
|
||||||
event.cancel();
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
Goal goal = new GoalBlock(waypoint.getLocation());
|
Goal goal = new GoalBlock(waypoint.getLocation());
|
||||||
PathingBehavior.INSTANCE.setGoal(goal);
|
PathingBehavior.INSTANCE.setGoal(goal);
|
||||||
|
Loading…
Reference in New Issue
Block a user