Merge pull request #3533 from Echocage/SprintFix

Fix for a sprint bug that can cause death
This commit is contained in:
Leijurv 2022-07-05 15:27:10 -07:00 committed by GitHub
commit a73e1185dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -73,8 +73,8 @@ public class PathExecutor implements IPathExecutor, Helper {
private HashSet<BlockPos> toPlace = new HashSet<>(); private HashSet<BlockPos> toPlace = new HashSet<>();
private HashSet<BlockPos> toWalkInto = new HashSet<>(); private HashSet<BlockPos> toWalkInto = new HashSet<>();
private PathingBehavior behavior; private final PathingBehavior behavior;
private IPlayerContext ctx; private final IPlayerContext ctx;
private boolean sprintNextTick; private boolean sprintNextTick;
@ -397,11 +397,20 @@ public class PathExecutor implements IPathExecutor, Helper {
return true; return true;
} }
if (canSprintFromDescendInto(ctx, current, next)) { if (canSprintFromDescendInto(ctx, current, next)) {
if (next instanceof MovementDescend && pathPosition < path.length() - 3) {
IMovement next_next = path.movements().get(pathPosition + 2);
if (next_next instanceof MovementDescend && !canSprintFromDescendInto(ctx, next, next_next)) {
return false;
}
}
if (ctx.playerFeet().equals(current.getDest())) { if (ctx.playerFeet().equals(current.getDest())) {
pathPosition++; pathPosition++;
onChangeInPathPosition(); onChangeInPathPosition();
onTick(); onTick();
} }
return true; return true;
} }
//logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection())); //logDebug("Turning off sprinting " + movement + " " + next + " " + movement.getDirection() + " " + next.getDirection().down() + " " + next.getDirection().down().equals(movement.getDirection()));