Minecraft-Console-Client/MinecraftClient/Pathing/Moves/Impl/MoveDiagonal.cs
BruceChen 9e6b689dd6 feat: add corner walk, sprint descend, and parkour descend moves
- MoveDiagonal: allow single-side-blocked diagonals (corner walk) so
  the bot can hug an open side to cut around a wall; both-sides-blocked
  remains impossible. Walk-speed cost when one side is blocked.
- MoveSprintDescend: sprint off a ledge covering 2 horizontal blocks
  while dropping 1-3 blocks. Registered for cardinal and diagonal
  offsets.
- MoveParkour: support negative yDelta (-1, -2) for descending parkour
  where the bot sprint-jumps across a gap and lands on a lower
  platform. Registered cardinal (dist 2-4, y-1/-2) and diagonal
  variants.
- DescendTemplate: sprint when horizontal distance > 1.5 blocks.
- SprintJumpTemplate: increase vertical landing tolerance for descend.

Made-with: Cursor
2026-04-12 18:43:32 +00:00

59 lines
1.9 KiB
C#

using MinecraftClient.Pathing.Core;
namespace MinecraftClient.Pathing.Moves.Impl
{
/// <summary>
/// Diagonal walk (1 block in both X and Z, same Y).
/// Allows corner walks: if one intermediate cardinal is blocked by a wall
/// but the other is clear, the player can hug the open side to cut the
/// corner. Both sides blocked is impossible (player AABB too wide).
/// </summary>
public sealed class MoveDiagonal : IMove
{
public MoveType Type => MoveType.Diagonal;
public int XOffset { get; }
public int ZOffset { get; }
public bool DynamicY => false;
public MoveDiagonal(int xOffset, int zOffset)
{
XOffset = xOffset;
ZOffset = zOffset;
}
public void Calculate(CalculationContext ctx, int x, int y, int z, ref MoveResult result)
{
int destX = x + XOffset;
int destZ = z + ZOffset;
if (!ctx.CanWalkThrough(destX, y, destZ) || !ctx.CanWalkThrough(destX, y + 1, destZ))
{
result.SetImpossible();
return;
}
if (!ctx.CanWalkOn(destX, y - 1, destZ))
{
result.SetImpossible();
return;
}
bool sideX = ctx.CanWalkThrough(x + XOffset, y, z) &&
ctx.CanWalkThrough(x + XOffset, y + 1, z);
bool sideZ = ctx.CanWalkThrough(x, y, z + ZOffset) &&
ctx.CanWalkThrough(x, y + 1, z + ZOffset);
if (!sideX && !sideZ)
{
result.SetImpossible();
return;
}
double cost = ctx.SprintCost * ActionCosts.DiagonalMultiplier;
if (!sideX || !sideZ)
cost = ctx.WalkCost * ActionCosts.DiagonalMultiplier;
result.Set(destX, y, destZ, cost);
}
}
}