Minecraft-Console-Client/MinecraftClient/Pathing/Execution/Templates/DescendTemplate.cs
BruceChen 53082d387e feat: add 4-block jumps, diagonal parkour, high-fall water/ladder support
MoveParkour rewritten to support both cardinal and diagonal sprint jumps
with unified (xOff, zOff) interface. New capabilities:

- 4-block cardinal sprint jumps with edge-approach timing in template
- Diagonal parkour: (2,1), (1,2), (2,2), (3,1), (1,3) in all quadrants
- Ascending parkour extended to dist=3 (cardinal)
- Overshoot safety check after landing destination
- Block parkour from climbable starting blocks (vine/ladder)

MoveDescend/MoveFall enhanced with Baritone-style dynamic fall scanning:
- Water landing: accepts falls of any height into water
- Mid-fall ladder/vine grab: resets effective fall height (<=11 blocks)
- CalculationContext gains MaxFallHeightWater, AllowLadderGrabDuringFall

SprintJumpTemplate gains distance-based approach timing:
- Long jumps (>=3.5 blocks): delays jump until 0.5 blocks from center
- Medium jumps (>=2.5): 0.35 blocks approach
- Landing tolerance scales with jump distance

All movements verified on 1.21.11 local server.

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

68 lines
2.2 KiB
C#

using System;
using MinecraftClient.Mapping;
using MinecraftClient.Physics;
namespace MinecraftClient.Pathing.Execution.Templates
{
/// <summary>
/// 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.
/// </summary>
public sealed class DescendTemplate : IActionTemplate
{
public Location ExpectedStart { get; }
public Location ExpectedEnd { get; }
private int _tickCount;
private bool _hasFallen;
public DescendTemplate(Location start, Location end)
{
ExpectedStart = start;
ExpectedEnd = end;
}
public TemplateState Tick(Location pos, PlayerPhysics physics, MovementInput input)
{
_tickCount++;
double dx = ExpectedEnd.X - pos.X;
double dz = ExpectedEnd.Z - pos.Z;
double dy = ExpectedEnd.Y - pos.Y;
double horizDistSq = dx * dx + dz * dz;
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 > 200)
return TemplateState.Failed;
if (horizDistSq > 0.01)
{
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
input.Forward = true;
if (physics.OnClimbable)
input.Forward = false;
}
return TemplateState.InProgress;
}
}
}