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