mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
- WalkTemplate: remove OnClimbable jump/sprint logic that caused the player to jump when walking past vine blocks during flat traversal - TemplateHelper: add CalculatePitch() for computing the look angle toward a 3D target relative to eye height - All templates (Walk, Ascend, Descend, Climb, SprintJump): set physics.Pitch each tick so the player visually looks toward the current path target direction - McClient: sync playerPitch and set _yaw/_pitch after pathfinding ticks so rotation is included in position update packets sent to the server Made-with: Cursor
52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using System;
|
|
using MinecraftClient.Mapping;
|
|
using MinecraftClient.Physics;
|
|
|
|
namespace MinecraftClient.Pathing.Execution.Templates
|
|
{
|
|
/// <summary>
|
|
/// Walk/sprint toward a destination on the same Y level.
|
|
/// Used for Traverse and Diagonal moves.
|
|
/// </summary>
|
|
public sealed class WalkTemplate : IActionTemplate
|
|
{
|
|
public Location ExpectedStart { get; }
|
|
public Location ExpectedEnd { get; }
|
|
|
|
private int _tickCount;
|
|
private Location _lastPos;
|
|
private int _stuckTicks;
|
|
|
|
public WalkTemplate(Location start, Location end)
|
|
{
|
|
ExpectedStart = start;
|
|
ExpectedEnd = end;
|
|
_lastPos = start;
|
|
}
|
|
|
|
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;
|
|
physics.Yaw = TemplateHelper.CalculateYaw(dx, dz);
|
|
physics.Pitch = TemplateHelper.CalculatePitch(dx, dy - 1.62, dz);
|
|
input.Forward = true;
|
|
input.Sprint = true;
|
|
|
|
if (TemplateHelper.IsNear(pos, ExpectedEnd, horizThresholdSq: 0.20))
|
|
return TemplateState.Complete;
|
|
|
|
double movedSq = TemplateHelper.HorizontalDistanceSq(pos, _lastPos);
|
|
_stuckTicks = movedSq < 0.0005 ? _stuckTicks + 1 : 0;
|
|
_lastPos = pos;
|
|
|
|
if (_stuckTicks > 40 || _tickCount > 100)
|
|
return TemplateState.Failed;
|
|
|
|
return TemplateState.InProgress;
|
|
}
|
|
}
|
|
}
|