Merge pull request #306 from babbaj/master

fix garbage code
This commit is contained in:
Leijurv 2019-01-08 21:56:19 -08:00
commit f5478f6169
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A

View File

@ -26,10 +26,10 @@ import baritone.api.process.IBaritoneProcess;
import baritone.api.process.PathingCommand;
import baritone.behavior.PathingBehavior;
import baritone.pathing.path.PathExecutor;
import java.util.stream.Stream;
import net.minecraft.util.math.BlockPos;
import java.util.*;
import java.util.stream.Collectors;
public class PathingControlManager implements IPathingControlManager {
private final Baritone baritone;
@ -170,30 +170,30 @@ public class PathingControlManager implements IPathingControlManager {
public PathingCommand doTheStuff() {
List<IBaritoneProcess> inContention = processes.stream().filter(IBaritoneProcess::isActive).sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()).collect(Collectors.toList());
boolean found = false;
boolean cancelOthers = false;
PathingCommand exec = null;
for (IBaritoneProcess proc : inContention) {
if (found) {
if (cancelOthers) {
proc.onLostControl();
}
} else {
exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
Stream<IBaritoneProcess> inContention = processes.stream()
.filter(IBaritoneProcess::isActive)
.sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed());
Iterator<IBaritoneProcess> iterator = inContention.iterator();
while(iterator.hasNext()) {
IBaritoneProcess proc = iterator.next();
PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
if (exec == null) {
if (proc.isActive()) {
throw new IllegalStateException(proc.displayName());
throw new IllegalStateException(proc.displayName() + " returned null PathingCommand");
}
proc.onLostControl();
continue;
}
//System.out.println("Executing command " + exec.commandType + " " + exec.goal + " from " + proc.displayName());
} else {
inControlThisTick = proc;
found = true;
cancelOthers = !proc.isTemporary();
}
if (!proc.isTemporary()) {
iterator.forEachRemaining(IBaritoneProcess::onLostControl);
}
return exec;
}
}
return null;
}
}