@@ -29,6 +29,7 @@ import com.lambda.util.BlockUtils.blockState
2929import com.lambda.util.CommunicationUtils.logError
3030import com.lambda.util.SpeedUnit
3131import com.lambda.util.math.dist
32+ import com.lambda.util.math.distSq
3233import com.lambda.util.math.flooredBlockPos
3334import com.lambda.util.math.isLoaded
3435import com.lambda.util.world.raycast.InteractionMask
@@ -88,6 +89,15 @@ abstract class ObstaclePassingMode(
8889 val closestLinePoint = playerPos.findClosestPointOnLine(snappedDir)
8990
9091 passingToPos?.let { passingTo ->
92+ if (passingTo distSq startPos < playerPos distSq startPos) {
93+ val atClosestPointBlockPos = closestLinePoint.flooredBlockPos == player.blockPos
94+ if (! atClosestPointBlockPos) pathToValidPoint(closestLinePoint, snappedDir, false )
95+ else {
96+ BaritoneHandler .cancel()
97+ passingToPos = null
98+ return @let
99+ }
100+ }
91101 if (passingTo.isObstructed(snappedDir)) {
92102 pathToValidPoint(passingTo, snappedDir)
93103 }
@@ -97,7 +107,7 @@ abstract class ObstaclePassingMode(
97107 if (! player.isOnGround) return false
98108
99109 val notProgressing = Speedometer .calculateSpeed(true , SpeedUnit .BlocksPerSecond ) < 0.01
100- if (player.isGliding && notProgressing) {
110+ if (notProgressing) {
101111 pathToValidPoint(closestLinePoint, snappedDir)
102112 return true
103113 }
@@ -110,7 +120,7 @@ abstract class ObstaclePassingMode(
110120 .dist(closestLinePoint) + (playerPos.y - closestLinePoint.y)
111121 .coerceAtMost(0.0 )
112122 if (distanceToLine > passerConfig.acceptableOffsetRange) {
113- pathToValidPoint(closestLinePoint, snappedDir, true )
123+ pathToValidPoint(closestLinePoint, snappedDir, false )
114124 return true
115125 }
116126
@@ -150,8 +160,8 @@ abstract class ObstaclePassingMode(
150160 return Vec3d (x, vector.y, z)
151161 }
152162
153- private fun SafeContext.pathToValidPoint (startSearchPos : Vec3d , dir : Vec3d , initialBlockedCheck : Boolean = false ) {
154- var skippingFirstCheck = ! initialBlockedCheck
163+ private fun SafeContext.pathToValidPoint (startSearchPos : Vec3d , dir : Vec3d , guaranteeOneSkip : Boolean = true ) {
164+ var skippingFirstCheck = guaranteeOneSkip
155165 var searchPos = startSearchPos
156166 while (skippingFirstCheck || searchPos.isObstructed(dir)) {
157167 searchPos = searchPos.add(dir.multiply(passerConfig.obstacleLookAhead.toDouble()))
0 commit comments