add option to manually blacklist closest

This commit is contained in:
Leijurv 2019-04-16 18:04:43 -07:00
parent a1a9b4e6b9
commit c136182e17
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 16 additions and 1 deletions

View File

@ -117,7 +117,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
}
// blacklist the closest block and its adjacent blocks
public synchronized void blacklistClosest() {
public synchronized boolean blacklistClosest() {
List<BlockPos> newBlacklist = new ArrayList<>();
knownLocations.stream().min(Comparator.comparingDouble(ctx.player()::getDistanceSq)).ifPresent(newBlacklist::add);
outer:
@ -140,6 +140,7 @@ public class GetToBlockProcess extends BaritoneProcessHelper implements IGetToBl
}
logDebug("Blacklisting unreachable locations " + newBlacklist);
blacklist.addAll(newBlacklist);
return !newBlacklist.isEmpty();
}
// safer than direct double comparison from distanceSq

View File

@ -35,6 +35,7 @@ import baritone.pathing.movement.CalculationContext;
import baritone.pathing.movement.Movement;
import baritone.pathing.movement.Moves;
import baritone.process.CustomGoalProcess;
import baritone.process.GetToBlockProcess;
import baritone.utils.pathing.SegmentedCalculator;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
@ -466,6 +467,19 @@ public class ExampleBaritoneControl extends Behavior implements Helper {
logDirect("Exploring from " + centerX + "," + centerZ);
return true;
}
if (msg.equals("blacklist")) {
GetToBlockProcess proc = baritone.getGetToBlockProcess();
if (!proc.isActive()) {
logDirect("GetToBlockProcess is not currently active");
return true;
}
if (proc.blacklistClosest()) {
logDirect("Blacklisted closest instances");
} else {
logDirect("No known locations, unable to blacklist");
}
return true;
}
if (msg.startsWith("find")) {
String blockType = msg.substring(4).trim();
ArrayList<BlockPos> locs = baritone.getWorldProvider().getCurrentWorld().getCachedWorld().getLocationsOf(blockType, 1, ctx.playerFeet().getX(), ctx.playerFeet().getZ(), 4);