mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Fix a cluster of execution-layer issues that caused replans and void falls when traversing narrow ledges and multi-block descents between (251.5,141,210.5) and (252.5,138,220.5): - WalkTemplate / GroundedSegmentController: suppress the pre-rotation bias toward the next segment's exit heading on stable-footing Turn exits where the next segment is not a jump. The next template snaps yaw on its first tick anyway, and pre-rotating mid-stride on a 1-block walkway pushes sprint drift perpendicular to the path and walks the bot off the edge. Turn exits into a jump still get the bias so the takeoff direction stays aligned. - GroundedSegmentController.ShouldComplete: relax the headingReady gate for Turn exits with stable footing so the segment can complete once yaw is aligned with either the current or the next segment heading (within 25/15 deg). Without this the removed bias would leave the bot stuck at the end of a walkway waiting for a rotation that never happens. - DescendTemplate: restrict the airborne exit-heading bias so it only kicks in when the footprint is inside the landing block, or on single-step drops where the fall is too short for lateral drift to miss the landing column. On 2+ block drops the bot now keeps yaw pointed at the landing center for the whole fall. - DescendTemplate: add a multi-block overshoot guard on PrepareJump exits. Once airborne and past the landing end-plane on a 2+ Y drop, release forward/sprint and press back briefly so air drag pulls the bot back into the 1x1 landing column instead of sailing one block past it into the neighbouring void. Live round-trip between the two goal coordinates now completes with zero replans in three consecutive runs in each direction. Full unit test suite is unchanged from the pre-existing baseline (22 failing tests, all orthogonal to this change). Made-with: Cursor
53 lines
2 KiB
C#
53 lines
2 KiB
C#
using Brigadier.NET;
|
|
using Brigadier.NET.Builder;
|
|
using MinecraftClient.CommandHandler;
|
|
using MinecraftClient.Mapping;
|
|
using static MinecraftClient.CommandHandler.CmdResult;
|
|
|
|
namespace MinecraftClient.Commands
|
|
{
|
|
public class Goto : Command
|
|
{
|
|
public override string CmdName => "goto";
|
|
public override string CmdUsage => "goto <x y z>";
|
|
public override string CmdDesc => Translations.cmd_goto_desc;
|
|
|
|
public override void RegisterCommand(CommandDispatcher<CmdResult> dispatcher)
|
|
{
|
|
dispatcher.Register(l => l.Literal("help")
|
|
.Then(l => l.Literal(CmdName)
|
|
.Executes(r => GetUsage(r.Source, string.Empty)))
|
|
);
|
|
|
|
dispatcher.Register(l => l.Literal(CmdName)
|
|
.Then(l => l.Argument("location", MccArguments.Location())
|
|
.Executes(r => DoGoto(r.Source, MccArguments.GetLocation(r, "location"))))
|
|
.Then(l => l.Literal("_help")
|
|
.Executes(r => GetUsage(r.Source, string.Empty))
|
|
.Redirect(dispatcher.GetRoot().GetChild("help").GetChild(CmdName)))
|
|
);
|
|
}
|
|
|
|
private int GetUsage(CmdResult r, string? cmd)
|
|
{
|
|
return r.SetAndReturn(GetCmdDescTranslated());
|
|
}
|
|
|
|
private static int DoGoto(CmdResult r, Location goal)
|
|
{
|
|
McClient handler = CmdResult.currentHandler!;
|
|
if (!handler.GetTerrainEnabled())
|
|
return r.SetAndReturn(Status.FailNeedTerrain);
|
|
|
|
Location current = handler.GetCurrentLocation();
|
|
goal.ToAbsolute(current);
|
|
|
|
// The A* search runs on a background task (see NavigateToGoal), so
|
|
// a generous budget no longer blocks the 20 TPS tick loop. Matches
|
|
// Baritone's multi-second default budget for interactive goto.
|
|
var (success, message) = handler.MoveToAStar(goal, timeoutMs: 15000);
|
|
|
|
return r.SetAndReturn(success ? Status.Done : Status.Fail, message);
|
|
}
|
|
}
|
|
}
|