MCPcopy Create free account
hub / github.com/boxbeam/RedLib / directPathfind

Method directPathfind

src/redempt/redlib/misc/LocationUtils.java:377–388  ·  view source on GitHub ↗

Finds the fastest path between a starting and ending location using A , then removes unneeded steps for straight @param start The starting block @param end The ending block @param max The max number of locations to be checked - use to limit runtime @param filter A filter to determine which b

(Block start, Block end, int max, Predicate<Block> filter)

Source from the content-addressed store, hash-verified

375 * be completed
376 */
377 public static List<Location> directPathfind(Block start, Block end, int max, Predicate<Block> filter) {
378 List<Location> path = new ArrayList<>(pathfind(start, end, max, filter));
379 for (int i = 0; i + 2 < path.size(); i += 2) {
380 Location first = path.get(i);
381 Location second = path.get(i + 2);
382 if (Path.getPath(first, second, 0.25).stream().map(Location::getBlock).allMatch(filter)) {
383 path.remove(i + 1);
384 i -= 2;
385 }
386 }
387 return path;
388 }
389
390 /**
391 * Finds the fastest path between a starting and ending location using A*, then removes unneeded steps for straight

Callers

nothing calls this directly

Calls 8

pathfindMethod · 0.95
getPathMethod · 0.95
mapMethod · 0.80
getMethod · 0.65
removeMethod · 0.65
sizeMethod · 0.45
streamMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected