This commit is contained in:
Leijurv 2019-01-08 22:00:33 -08:00
parent f5478f6169
commit a4495ce80a
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.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.Stream;
public class PathingControlManager implements IPathingControlManager { public class PathingControlManager implements IPathingControlManager {
private final Baritone baritone; private final Baritone baritone;
@ -82,7 +82,7 @@ public class PathingControlManager implements IPathingControlManager {
public void preTick() { public void preTick() {
inControlLastTick = inControlThisTick; inControlLastTick = inControlThisTick;
command = doTheStuff(); command = executeProcesses();
if (command == null) { if (command == null) {
return; return;
} }
@ -169,14 +169,14 @@ public class PathingControlManager implements IPathingControlManager {
} }
public PathingCommand doTheStuff() { public PathingCommand executeProcesses() {
Stream<IBaritoneProcess> inContention = processes.stream() Stream<IBaritoneProcess> inContention = processes.stream()
.filter(IBaritoneProcess::isActive) .filter(IBaritoneProcess::isActive)
.sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed()); .sorted(Comparator.comparingDouble(IBaritoneProcess::priority).reversed());
Iterator<IBaritoneProcess> iterator = inContention.iterator(); Iterator<IBaritoneProcess> iterator = inContention.iterator();
while(iterator.hasNext()) { while (iterator.hasNext()) {
IBaritoneProcess proc = iterator.next(); IBaritoneProcess proc = iterator.next();
PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel()); PathingCommand exec = proc.onTick(Objects.equals(proc, inControlLastTick) && baritone.getPathingBehavior().calcFailedLastTick(), baritone.getPathingBehavior().isSafeToCancel());
@ -190,7 +190,6 @@ public class PathingControlManager implements IPathingControlManager {
if (!proc.isTemporary()) { if (!proc.isTemporary()) {
iterator.forEachRemaining(IBaritoneProcess::onLostControl); iterator.forEachRemaining(IBaritoneProcess::onLostControl);
} }
return exec; return exec;
} }
} }