begone betterblockpos

This commit is contained in:
Leijurv 2018-09-23 08:54:26 -07:00
parent 23c11a5170
commit cc01c88dbd
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 7 additions and 6 deletions

View File

@ -41,8 +41,11 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.EmptyChunk;
import java.awt.*;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Optional;
import java.util.stream.Collectors;
public final class PathingBehavior extends Behavior implements Helper {
@ -329,8 +332,9 @@ public final class PathingBehavior extends Behavior implements Helper {
} else {
timeout = Baritone.settings().planAheadTimeoutMS.<Long>get();
}
Optional<HashSet<Long>> favoredPositions = previous.map(IPath::positions).map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC
try {
IPathFinder pf = new AStarPathFinder(start, goal, previous.map(IPath::positions));
IPathFinder pf = new AStarPathFinder(start, goal, favoredPositions);
return pf.calculate(timeout);
} catch (Exception e) {
logDebug("Pathing exception: " + e);

View File

@ -27,15 +27,12 @@ import baritone.pathing.movement.CalculationContext;
import baritone.pathing.path.IPath;
import baritone.utils.BlockStateInterface;
import baritone.utils.Helper;
import baritone.utils.pathing.BetterBlockPos;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ChunkProviderClient;
import net.minecraft.util.math.BlockPos;
import java.util.Collection;
import java.util.HashSet;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* The actual A* pathfinding
@ -46,9 +43,9 @@ public final class AStarPathFinder extends AbstractNodeCostSearch implements Hel
private final Optional<HashSet<Long>> favoredPositions;
public AStarPathFinder(BlockPos start, Goal goal, Optional<Collection<BetterBlockPos>> favoredPositions) {
public AStarPathFinder(BlockPos start, Goal goal, Optional<HashSet<Long>> favoredPositions) {
super(start, goal);
this.favoredPositions = favoredPositions.map(Collection::stream).map(x -> x.map(y -> y.hashCode)).map(x -> x.collect(Collectors.toList())).map(HashSet::new); // <-- okay this is EPIC
this.favoredPositions = favoredPositions;
}
@Override