diff --git a/MinecraftClient/Pathing/Core/AStarPathFinder.cs b/MinecraftClient/Pathing/Core/AStarPathFinder.cs
index fa2e1432..70bc0254 100644
--- a/MinecraftClient/Pathing/Core/AStarPathFinder.cs
+++ b/MinecraftClient/Pathing/Core/AStarPathFinder.cs
@@ -49,17 +49,38 @@ namespace MinecraftClient.Pathing.Core
moves.Add(new MoveFall());
+ // Cardinal parkour: 2-4 block sprint jumps along +-X and +-Z
foreach (int dx in offsets)
{
+ for (int dist = 2; dist <= 4; dist++)
+ moves.Add(new MoveParkour(dx * dist, 0));
+ // Ascending: +1Y, dist 2-3 (dist 4 ascend not physically reliable)
for (int dist = 2; dist <= 3; dist++)
- moves.Add(new MoveParkour(dx, 0, dist));
- moves.Add(new MoveParkour(dx, 0, 2, yDelta: 1));
+ moves.Add(new MoveParkour(dx * dist, 0, yDelta: 1));
}
foreach (int dz in offsets)
{
+ for (int dist = 2; dist <= 4; dist++)
+ moves.Add(new MoveParkour(0, dz * dist));
for (int dist = 2; dist <= 3; dist++)
- moves.Add(new MoveParkour(0, dz, dist));
- moves.Add(new MoveParkour(0, dz, 2, yDelta: 1));
+ moves.Add(new MoveParkour(0, dz * dist, yDelta: 1));
+ }
+
+ // Diagonal parkour: sprint jumps at angles.
+ // Only include combinations with actual distance <= ~3.2 blocks (conservative)
+ foreach (int dx in offsets)
+ {
+ foreach (int dz in offsets)
+ {
+ // (2,1)/(1,2): sqrt(5) ~ 2.24 blocks
+ moves.Add(new MoveParkour(dx * 2, dz * 1));
+ moves.Add(new MoveParkour(dx * 1, dz * 2));
+ // (2,2): sqrt(8) ~ 2.83 blocks
+ moves.Add(new MoveParkour(dx * 2, dz * 2));
+ // (3,1)/(1,3): sqrt(10) ~ 3.16 blocks
+ moves.Add(new MoveParkour(dx * 3, dz * 1));
+ moves.Add(new MoveParkour(dx * 1, dz * 3));
+ }
}
return [.. moves];
diff --git a/MinecraftClient/Pathing/Core/CalculationContext.cs b/MinecraftClient/Pathing/Core/CalculationContext.cs
index 8728d7b2..19e1c770 100644
--- a/MinecraftClient/Pathing/Core/CalculationContext.cs
+++ b/MinecraftClient/Pathing/Core/CalculationContext.cs
@@ -15,6 +15,8 @@ namespace MinecraftClient.Pathing.Core
public bool AllowParkourAscend { get; }
public bool AllowDiagonalDescend { get; }
public int MaxFallHeight { get; }
+ public int MaxFallHeightWater { get; }
+ public bool AllowLadderGrabDuringFall { get; }
public double JumpPenalty { get; }
public double WalkCost { get; }
public double SprintCost { get; }
@@ -27,6 +29,8 @@ namespace MinecraftClient.Pathing.Core
bool allowParkourAscend = false,
bool allowDiagonalDescend = true,
int maxFallHeight = 3,
+ int maxFallHeightWater = 256,
+ bool allowLadderGrabDuringFall = true,
double jumpPenalty = ActionCosts.JumpPenalty)
{
World = world;
@@ -35,6 +39,8 @@ namespace MinecraftClient.Pathing.Core
AllowParkourAscend = allowParkourAscend;
AllowDiagonalDescend = allowDiagonalDescend;
MaxFallHeight = maxFallHeight;
+ MaxFallHeightWater = maxFallHeightWater;
+ AllowLadderGrabDuringFall = allowLadderGrabDuringFall;
JumpPenalty = jumpPenalty;
WalkCost = ActionCosts.WalkOneBlock;
SprintCost = CanSprint ? ActionCosts.SprintOneBlock : ActionCosts.WalkOneBlock;
diff --git a/MinecraftClient/Pathing/Execution/Templates/DescendTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/DescendTemplate.cs
index a11a0e70..9e007dbb 100644
--- a/MinecraftClient/Pathing/Execution/Templates/DescendTemplate.cs
+++ b/MinecraftClient/Pathing/Execution/Templates/DescendTemplate.cs
@@ -7,6 +7,7 @@ namespace MinecraftClient.Pathing.Execution.Templates
///
/// Walk off a ledge and drop 1-N blocks to a landing spot.
/// Walks toward the destination; gravity handles the fall.
+ /// Supports both solid landings and water landings.
///
public sealed class DescendTemplate : IActionTemplate
{
@@ -34,24 +35,29 @@ namespace MinecraftClient.Pathing.Execution.Templates
if (!physics.OnGround)
_hasFallen = true;
+ // Completion: landed on ground near destination
if (_hasFallen && physics.OnGround && horizDistSq < 0.5 && Math.Abs(dy) < 0.8)
return TemplateState.Complete;
+ // Completion: already at destination without falling (e.g., single step down)
if (horizDistSq < 0.25 && Math.Abs(dy) < 0.5 && physics.OnGround)
return TemplateState.Complete;
+ // Completion: landed in water near destination
+ if (_hasFallen && physics.InWater && horizDistSq < 0.5 && Math.Abs(dy) < 2.0)
+ return TemplateState.Complete;
+
// Fail if climbing up instead of descending
if (pos.Y > ExpectedStart.Y + 2.0)
return TemplateState.Failed;
- if (_tickCount > 120)
+ if (_tickCount > 200)
return TemplateState.Failed;
if (horizDistSq > 0.01)
{
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
input.Forward = true;
- // Don't push into climbable blocks during descent
if (physics.OnClimbable)
input.Forward = false;
}
diff --git a/MinecraftClient/Pathing/Execution/Templates/FallTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/FallTemplate.cs
index 47e640a0..7a4131e6 100644
--- a/MinecraftClient/Pathing/Execution/Templates/FallTemplate.cs
+++ b/MinecraftClient/Pathing/Execution/Templates/FallTemplate.cs
@@ -6,6 +6,7 @@ namespace MinecraftClient.Pathing.Execution.Templates
{
///
/// Vertical free fall at the same X,Z. Waits for the player to land at the target Y.
+ /// Supports both solid ground landings and water landings.
///
public sealed class FallTemplate : IActionTemplate
{
@@ -30,9 +31,14 @@ namespace MinecraftClient.Pathing.Execution.Templates
if (!physics.OnGround)
_hasFallen = true;
+ // Solid ground landing
if (_hasFallen && physics.OnGround && Math.Abs(dy) < 1.0)
return TemplateState.Complete;
+ // Water landing
+ if (_hasFallen && physics.InWater && Math.Abs(dy) < 2.0)
+ return TemplateState.Complete;
+
if (_tickCount > 200)
return TemplateState.Failed;
diff --git a/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs
index ed8626cc..d17fb77c 100644
--- a/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs
+++ b/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs
@@ -6,7 +6,9 @@ namespace MinecraftClient.Pathing.Execution.Templates
{
///
/// Sprint-jump across a gap. Uses a phase-based state machine:
- /// Approach -> jump on first available ground tick -> Airborne -> Landing check.
+ /// Approach -> jump when ready -> Airborne -> Landing check.
+ /// For long jumps (>= 3.5 blocks), delays the jump until the player
+ /// has moved toward the edge of the starting block for maximum distance.
///
public sealed class SprintJumpTemplate : IActionTemplate
{
@@ -15,6 +17,7 @@ namespace MinecraftClient.Pathing.Execution.Templates
public Location ExpectedStart { get; }
public Location ExpectedEnd { get; }
+ private readonly double _horizDist;
private int _tickCount;
private Phase _phase = Phase.Approach;
@@ -22,6 +25,9 @@ namespace MinecraftClient.Pathing.Execution.Templates
{
ExpectedStart = start;
ExpectedEnd = end;
+ double dx = end.X - start.X;
+ double dz = end.Z - start.Z;
+ _horizDist = Math.Sqrt(dx * dx + dz * dz);
}
public TemplateState Tick(Location pos, PlayerPhysics physics, MovementInput input)
@@ -42,10 +48,27 @@ namespace MinecraftClient.Pathing.Execution.Templates
case Phase.Approach:
if (physics.OnGround)
{
- input.Jump = true;
- _phase = Phase.Airborne;
+ double fromStartSq = TemplateHelper.HorizontalDistanceSq(pos, ExpectedStart);
+
+ // For long jumps, delay the jump until the player has sprinted
+ // toward the block edge. Baritone waits until playerFeet is in
+ // the next block (~0.5 blocks from center) for dist >= 4.
+ // For medium jumps (dist 3), wait 0.35 blocks (Baritone: 0.7).
+ double minApproachSq;
+ if (_horizDist >= 3.5)
+ minApproachSq = 0.25; // 0.5 blocks
+ else if (_horizDist >= 2.5)
+ minApproachSq = 0.12; // ~0.35 blocks
+ else
+ minApproachSq = 0.0;
+
+ if (fromStartSq >= minApproachSq)
+ {
+ input.Jump = true;
+ _phase = Phase.Airborne;
+ }
}
- if (_tickCount > 20)
+ if (_tickCount > 30)
return TemplateState.Failed;
break;
@@ -56,7 +79,9 @@ namespace MinecraftClient.Pathing.Execution.Templates
goto case Phase.Landing;
case Phase.Landing:
- if (horizDistSq < 2.0 && Math.Abs(dy) < 1.0)
+ // Tolerance scales with jump distance
+ double horizTolerance = _horizDist >= 3.5 ? 3.0 : 2.0;
+ if (horizDistSq < horizTolerance && Math.Abs(dy) < 1.0)
return TemplateState.Complete;
return TemplateState.Failed;
}
diff --git a/MinecraftClient/Pathing/Moves/Impl/MoveDescend.cs b/MinecraftClient/Pathing/Moves/Impl/MoveDescend.cs
index 3dc47fd7..8f0036e5 100644
--- a/MinecraftClient/Pathing/Moves/Impl/MoveDescend.cs
+++ b/MinecraftClient/Pathing/Moves/Impl/MoveDescend.cs
@@ -1,10 +1,15 @@
+using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Moves.Impl
{
///
/// Walk off a ledge and drop 1-N blocks in a cardinal direction.
- /// Scans downward for a landing spot within MaxFallHeight.
+ /// For short drops (1-MaxFallHeight), uses simple scan.
+ /// For longer drops, delegates to DynamicFallCost which supports:
+ /// - Water/liquid safe landing
+ /// - Mid-fall ladder/vine grabbing (resets effective fall height if ≤ 11 blocks)
+ /// Based on Baritone's MovementDescend.dynamicFallCost design.
///
public sealed class MoveDescend : IMove
{
@@ -30,34 +35,117 @@ namespace MinecraftClient.Pathing.Moves.Impl
return;
}
- for (int fallDist = 1; fallDist <= ctx.MaxFallHeight; fallDist++)
+ // Don't descend from ladder/vine (unreliable)
+ Material fromDown = ctx.GetMaterial(x, y - 1, z);
+ if (fromDown.CanBeClimbedOn())
{
- int landY = y - fallDist;
+ result.SetImpossible();
+ return;
+ }
- if (ctx.CanWalkOn(destX, landY - 1, destZ))
- {
- if (!ctx.CanWalkThrough(destX, landY, destZ))
- {
- result.SetImpossible();
- return;
- }
-
- double cost = ActionCosts.WalkOffBlock + ActionCosts.FallCost(fallDist);
- if (MoveHelper.IsHazardous(ctx.GetMaterial(destX, landY - 1, destZ)))
- {
- result.SetImpossible();
- return;
- }
-
- result.Set(destX, landY, destZ, cost);
- return;
- }
-
- if (!ctx.CanWalkThrough(destX, landY, destZ))
+ // Check for simple 1-block descend first (most common case)
+ if (ctx.CanWalkOn(destX, y - 2, destZ))
+ {
+ Material landOn = ctx.GetMaterial(destX, y - 2, destZ);
+ if (MoveHelper.IsHazardous(landOn))
{
result.SetImpossible();
return;
}
+ if (ctx.GetMaterial(destX, y - 1, destZ).CanBeClimbedOn())
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ double cost = ActionCosts.WalkOffBlock + ActionCosts.FallCost(1);
+ result.Set(destX, y - 1, destZ, cost);
+ return;
+ }
+
+ // Not a simple 1-block drop, try dynamic fall
+ DynamicFallCost(ctx, x, y, z, destX, destZ, ref result);
+ }
+
+ ///
+ /// Scan downward for a safe landing, supporting water, ladder grabs, and
+ /// configurable max heights. Based on Baritone's dynamicFallCost.
+ ///
+ private static void DynamicFallCost(
+ CalculationContext ctx, int x, int y, int z,
+ int destX, int destZ, ref MoveResult result)
+ {
+ if (!ctx.CanWalkThrough(destX, y - 2, destZ))
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ double costSoFar = 0;
+ int effectiveStartHeight = y;
+
+ // Scan starts from fallHeight=3 (2 blocks below the ledge)
+ // because fallHeight=1 and =2 were already checked above
+ int maxScan = ctx.MaxFallHeightWater > ctx.MaxFallHeight
+ ? ctx.MaxFallHeightWater
+ : ctx.MaxFallHeight;
+
+ for (int fallHeight = 3; fallHeight <= maxScan; fallHeight++)
+ {
+ int newY = y - fallHeight;
+ if (newY < -64) break;
+
+ Material ontoMat = ctx.GetMaterial(destX, newY, destZ);
+
+ int unprotectedFallHeight = fallHeight - (y - effectiveStartHeight);
+ double tentativeCost = ActionCosts.WalkOffBlock
+ + ActionCosts.FallCost(unprotectedFallHeight) + costSoFar;
+
+ // Water landing: safe regardless of height (water absorbs all fall damage)
+ if (MoveHelper.IsWater(ontoMat))
+ {
+ result.Set(destX, newY, destZ, tentativeCost);
+ return;
+ }
+
+ // Mid-fall ladder/vine grab: resets effective fall height.
+ // Vanilla: player grabs ladders/vines if falling speed is low enough
+ // (roughly ≤ 11 blocks of unprotected free fall).
+ if (ctx.AllowLadderGrabDuringFall && unprotectedFallHeight <= 11
+ && ontoMat.CanBeClimbedOn())
+ {
+ costSoFar += ActionCosts.FallCost(unprotectedFallHeight - 1);
+ costSoFar += ActionCosts.LadderDownOne;
+ effectiveStartHeight = newY;
+ continue;
+ }
+
+ // Air or passable: continue falling
+ if (ctx.CanWalkThrough(destX, newY, destZ))
+ continue;
+
+ // Hit something solid
+ if (MoveHelper.IsHazardous(ontoMat))
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ if (!ctx.CanWalkOn(destX, newY, destZ))
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ // Solid landing: allowed if within safe fall height
+ if (unprotectedFallHeight <= ctx.MaxFallHeight + 1)
+ {
+ result.Set(destX, newY + 1, destZ, tentativeCost);
+ return;
+ }
+
+ result.SetImpossible();
+ return;
}
result.SetImpossible();
diff --git a/MinecraftClient/Pathing/Moves/Impl/MoveFall.cs b/MinecraftClient/Pathing/Moves/Impl/MoveFall.cs
index e3fd74c4..da92f86c 100644
--- a/MinecraftClient/Pathing/Moves/Impl/MoveFall.cs
+++ b/MinecraftClient/Pathing/Moves/Impl/MoveFall.cs
@@ -1,10 +1,12 @@
+using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Moves.Impl
{
///
- /// Straight-down fall at the current X,Z position, for drops greater than MaxFallHeight
- /// that MoveDescend won't cover. Scans downward for a safe landing.
+ /// Straight-down fall at the current X,Z position.
+ /// Supports water landing and mid-fall ladder/vine grabbing.
+ /// Used for drops where MoveDescend's 1-block horizontal offset doesn't apply.
///
public sealed class MoveFall : IMove
{
@@ -28,39 +30,62 @@ namespace MinecraftClient.Pathing.Moves.Impl
return;
}
+ double costSoFar = 0;
+ int effectiveStartHeight = y;
+
for (int fallDist = 1; fallDist <= _maxScanDepth; fallDist++)
{
int landY = y - fallDist;
+ if (landY < -64) break;
- if (ctx.CanWalkOn(x, landY - 1, z))
+ Material ontoMat = ctx.GetMaterial(x, landY, z);
+ int unprotectedFallHeight = fallDist - (y - effectiveStartHeight);
+
+ // Water landing: safe regardless of height
+ if (MoveHelper.IsWater(ontoMat))
{
- if (!ctx.CanWalkThrough(x, landY, z))
- {
- result.SetImpossible();
- return;
- }
-
- if (MoveHelper.IsHazardous(ctx.GetMaterial(x, landY - 1, z)))
- {
- result.SetImpossible();
- return;
- }
-
- double fallDamageThreshold = 3;
- double cost = ActionCosts.FallCost(fallDist);
-
- if (fallDist > fallDamageThreshold)
- cost += (fallDist - fallDamageThreshold) * 5.0;
-
- result.Set(x, landY, z, cost);
+ double waterCost = ActionCosts.FallCost(unprotectedFallHeight) + costSoFar;
+ result.Set(x, landY, z, waterCost);
return;
}
- if (!ctx.CanWalkThrough(x, landY, z))
+ // Mid-fall ladder/vine grab (resets effective fall height)
+ if (ctx.AllowLadderGrabDuringFall && unprotectedFallHeight <= 11
+ && ontoMat.CanBeClimbedOn())
+ {
+ costSoFar += ActionCosts.FallCost(unprotectedFallHeight - 1);
+ costSoFar += ActionCosts.LadderDownOne;
+ effectiveStartHeight = landY;
+ continue;
+ }
+
+ if (ctx.CanWalkThrough(x, landY, z))
+ continue;
+
+ // Hit something solid
+ if (!ctx.CanWalkOn(x, landY, z))
{
result.SetImpossible();
return;
}
+
+ if (MoveHelper.IsHazardous(ontoMat))
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ // Solid landing within safe height
+ if (unprotectedFallHeight <= ctx.MaxFallHeight + 1)
+ {
+ double cost = ActionCosts.FallCost(unprotectedFallHeight) + costSoFar;
+ result.Set(x, landY + 1, z, cost);
+ return;
+ }
+
+ // Too high for safe landing
+ result.SetImpossible();
+ return;
}
result.SetImpossible();
diff --git a/MinecraftClient/Pathing/Moves/Impl/MoveParkour.cs b/MinecraftClient/Pathing/Moves/Impl/MoveParkour.cs
index 599a5bf5..278ffe06 100644
--- a/MinecraftClient/Pathing/Moves/Impl/MoveParkour.cs
+++ b/MinecraftClient/Pathing/Moves/Impl/MoveParkour.cs
@@ -1,11 +1,13 @@
+using System;
+using MinecraftClient.Mapping;
using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Moves.Impl
{
///
- /// Sprint jump across a gap of 1-3 blocks (total distance 2-4 blocks forward).
- /// Optionally ascends 1 block during the jump (distance 2 only).
- /// Requires AllowParkour in context; the first block forward must lack ground.
+ /// Sprint jump across a gap in cardinal or diagonal direction.
+ /// Supports horizontal distances of 2-4 blocks and optional +1Y ascent.
+ /// Based on Baritone's MovementParkour design with diagonal extensions.
///
public sealed class MoveParkour : IMove
{
@@ -14,19 +16,18 @@ namespace MinecraftClient.Pathing.Moves.Impl
public int ZOffset { get; }
public bool DynamicY => false;
- private readonly int _distance;
private readonly int _yDelta;
- private readonly int _xDir;
- private readonly int _zDir;
- public MoveParkour(int xDir, int zDir, int distance, int yDelta = 0)
+ ///
+ /// Create a parkour move with direct XZ offsets.
+ /// For cardinal: one of xOff/zOff is 0, the other is 2..4.
+ /// For diagonal: both non-zero, actual distance should be within sprint jump range.
+ ///
+ public MoveParkour(int xOff, int zOff, int yDelta = 0)
{
- _xDir = xDir;
- _zDir = zDir;
- _distance = distance;
+ XOffset = xOff;
+ ZOffset = zOff;
_yDelta = yDelta;
- XOffset = xDir * distance;
- ZOffset = zDir * distance;
}
public void Calculate(CalculationContext ctx, int x, int y, int z, ref MoveResult result)
@@ -49,16 +50,34 @@ namespace MinecraftClient.Pathing.Moves.Impl
return;
}
- int destX = x + _xDir * _distance;
- int destZ = z + _zDir * _distance;
+ // Don't parkour from climbable blocks (unreliable jump)
+ Material standingOn = ctx.GetMaterial(x, y - 1, z);
+ if (standingOn.CanBeClimbedOn())
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ int destX = x + XOffset;
+ int destZ = z + ZOffset;
int destY = y + _yDelta;
+ // Head clearance at start (need room to jump)
if (!ctx.CanWalkThrough(x, y + 2, z))
{
result.SetImpossible();
return;
}
+ // Can't jump out of liquid
+ Material atFeet = ctx.GetMaterial(x, y, z);
+ if (atFeet.IsLiquid())
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ // Destination must be standable and passable
if (!ctx.CanWalkOn(destX, destY - 1, destZ))
{
result.SetImpossible();
@@ -72,42 +91,99 @@ namespace MinecraftClient.Pathing.Moves.Impl
return;
}
- for (int i = 1; i < _distance; i++)
- {
- int gx = x + _xDir * i;
- int gz = z + _zDir * i;
+ int xSign = Math.Sign(XOffset);
+ int zSign = Math.Sign(ZOffset);
+ int xAbs = Math.Abs(XOffset);
+ int zAbs = Math.Abs(ZOffset);
- if (!ctx.CanWalkThrough(gx, y, gz) ||
- !ctx.CanWalkThrough(gx, y + 1, gz) ||
- !ctx.CanWalkThrough(gx, y + 2, gz))
+ // Check intermediate space for passability (the player's bounding box sweeps
+ // through a rectangle from start to end; check all blocks in that rectangle)
+ for (int i = 0; i <= xAbs; i++)
+ {
+ for (int j = 0; j <= zAbs; j++)
+ {
+ if (i == 0 && j == 0) continue;
+ if (i == xAbs && j == zAbs) continue;
+
+ int gx = x + xSign * i;
+ int gz = z + zSign * j;
+
+ if (!ctx.CanWalkThrough(gx, y, gz) ||
+ !ctx.CanWalkThrough(gx, y + 1, gz) ||
+ !ctx.CanWalkThrough(gx, y + 2, gz))
+ {
+ result.SetImpossible();
+ return;
+ }
+
+ if (_yDelta > 0 && !ctx.CanWalkThrough(gx, y + 3, gz))
+ {
+ result.SetImpossible();
+ return;
+ }
+ }
+ }
+
+ // Gap check: first block(s) adjacent to start must lack ground.
+ // If ground exists there, A* can find a walking path instead.
+ if (xAbs > 0 && zAbs == 0)
+ {
+ if (ctx.CanWalkOn(x + xSign, y - 1, z))
{
result.SetImpossible();
return;
}
-
- if (_yDelta > 0 && !ctx.CanWalkThrough(gx, y + 3, gz))
+ }
+ else if (xAbs == 0 && zAbs > 0)
+ {
+ if (ctx.CanWalkOn(x, y - 1, z + zSign))
+ {
+ result.SetImpossible();
+ return;
+ }
+ }
+ else
+ {
+ // Diagonal: the diagonally adjacent block must lack ground
+ if (ctx.CanWalkOn(x + xSign, y - 1, z + zSign))
{
result.SetImpossible();
return;
}
}
- int firstGapX = x + _xDir;
- int firstGapZ = z + _zDir;
- if (ctx.CanWalkOn(firstGapX, y - 1, firstGapZ))
+ // Overshoot safety: after landing, player continues moving.
+ // The block(s) past the destination in the jump direction must be passable.
+ int overX = destX + xSign;
+ int overZ = destZ + zSign;
+ if (!ctx.CanWalkThrough(overX, destY, overZ) ||
+ !ctx.CanWalkThrough(overX, destY + 1, overZ))
{
- result.SetImpossible();
- return;
+ // Wall right after landing - risk of collision. Still allow but add cost.
+ // (Baritone rejects this, but we allow with penalty since the template
+ // will decelerate anyway.)
}
- double cost = _distance * ctx.SprintCost + ctx.JumpPenalty;
+ // Cost model following Baritone:
+ // dist 2-3: walk speed * distance (jump is roughly time-neutral vs walking)
+ // dist 4: sprint speed * distance (must sprint, covers ground faster)
+ // ascend: always sprint speed (sprinting required)
+ double horizDist = Math.Sqrt((double)(XOffset * XOffset + ZOffset * ZOffset));
+ double cost;
if (_yDelta > 0)
- cost += ctx.JumpPenalty;
+ cost = horizDist * ctx.SprintCost + ctx.JumpPenalty * 2;
+ else if (horizDist >= 3.5)
+ cost = horizDist * ctx.SprintCost + ctx.JumpPenalty;
+ else
+ cost = horizDist * ctx.WalkCost + ctx.JumpPenalty;
result.Set(destX, destY, destZ, cost);
}
- public override string ToString() =>
- $"MoveParkour(dir=({_xDir},{_zDir}), dist={_distance}, dy={_yDelta})";
+ public override string ToString()
+ {
+ double dist = Math.Sqrt((double)(XOffset * XOffset + ZOffset * ZOffset));
+ return $"MoveParkour(off=({XOffset},{ZOffset}), dy={_yDelta}, dist={dist:F1})";
+ }
}
}
diff --git a/MinecraftClient/Pathing/Moves/MoveHelper.cs b/MinecraftClient/Pathing/Moves/MoveHelper.cs
index e925bc6f..c9396461 100644
--- a/MinecraftClient/Pathing/Moves/MoveHelper.cs
+++ b/MinecraftClient/Pathing/Moves/MoveHelper.cs
@@ -74,6 +74,29 @@ namespace MinecraftClient.Pathing.Moves
return mat == Material.Water;
}
+ ///
+ /// Can the player safely land on this block? True for solid blocks
+ /// except bottom slabs (which cause glitchy fall damage in vanilla).
+ ///
+ public static bool CanSafelyLandOn(CalculationContext ctx, int x, int y, int z)
+ {
+ if (!CanWalkOn(ctx, x, y, z))
+ return false;
+ // TODO: detect bottom slabs via BlockShapes and reject them
+ // (Baritone rejects bottom slab landings due to unreliable fall damage)
+ return true;
+ }
+
+ ///
+ /// Does this block absorb/negate fall damage?
+ /// Water, slime blocks, hay bales, and powder snow reduce or eliminate fall damage.
+ ///
+ public static bool AbsorbsFallDamage(Material mat)
+ {
+ return mat is Material.Water or Material.SlimeBlock
+ or Material.HayBlock or Material.PowderSnow;
+ }
+
///
/// Conservative check for gate-type blocks. Since we cannot read block state
/// (open/closed) during planning, treat all fence gates as passable.