Undid previous change, updated to instead check the next and the next_next block

This commit is contained in:
Echocage 2022-06-27 18:38:54 -05:00
parent 2741fc2683
commit 57c4f9e103

View File

@ -385,7 +385,7 @@ public class PathExecutor implements IPathExecutor, Helper {
return false; return false;
} }
if (pathPosition < path.length() - 2) { if (pathPosition < path.length() - 3) {
IMovement next = path.movements().get(pathPosition + 1); IMovement next = path.movements().get(pathPosition + 1);
if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) { if (next instanceof MovementAscend && current.getDirection().up().equals(next.getDirection().down())) {
// a descend then an ascend in the same direction // a descend then an ascend in the same direction
@ -396,7 +396,8 @@ public class PathExecutor implements IPathExecutor, Helper {
logDebug("Skipping descend to straight ascend"); logDebug("Skipping descend to straight ascend");
return true; return true;
} }
if (canSprintFromDescendInto(ctx, current, next)) { if (canSprintFromDescendInto(ctx, current, next) &&
canSprintFromDescendInto(ctx, next, path.movements().get(pathPosition + 2))) {
if (ctx.playerFeet().equals(current.getDest())) { if (ctx.playerFeet().equals(current.getDest())) {
pathPosition++; pathPosition++;
onChangeInPathPosition(); onChangeInPathPosition();
@ -536,12 +537,12 @@ public class PathExecutor implements IPathExecutor, Helper {
} }
private static boolean canSprintFromDescendInto(IPlayerContext ctx, IMovement current, IMovement next) { private static boolean canSprintFromDescendInto(IPlayerContext ctx, IMovement current, IMovement next) {
if (!MovementHelper.canWalkOn(ctx, current.getDest().add(current.getDirection()))) {
return false;
}
if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) { if (next instanceof MovementDescend && next.getDirection().equals(current.getDirection())) {
return true; return true;
} }
if (!MovementHelper.canWalkOn(ctx, current.getDest().add(current.getDirection()))) {
return false;
}
if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection())) { if (next instanceof MovementTraverse && next.getDirection().down().equals(current.getDirection())) {
return true; return true;
} }