diff --git a/MinecraftClient/Pathing/Execution/Templates/AscendTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/AscendTemplate.cs index 393cfb66..8a96c041 100644 --- a/MinecraftClient/Pathing/Execution/Templates/AscendTemplate.cs +++ b/MinecraftClient/Pathing/Execution/Templates/AscendTemplate.cs @@ -33,8 +33,13 @@ namespace MinecraftClient.Pathing.Execution.Templates double dy = ExpectedEnd.Y - pos.Y; double horizDistSq = dx * dx + dz * dz; - // Complete when close to destination. Sprint bouncing can leave the player - // slightly above ground, so we don't require OnGround here. + physics.Yaw = TemplateHelper.CalculateYaw(dx, dz); + input.Forward = true; + input.Sprint = true; + + if (physics.OnGround && dy > 0.1) + input.Jump = true; + if (horizDistSq < 0.25 && Math.Abs(dy) < 0.8) return TemplateState.Complete; @@ -46,13 +51,6 @@ namespace MinecraftClient.Pathing.Execution.Templates if (_stuckTicks > 40 || _tickCount > 80) return TemplateState.Failed; - physics.Yaw = TemplateHelper.CalculateYaw(dx, dz); - input.Forward = true; - input.Sprint = true; - - if (physics.OnGround && dy > 0.1) - input.Jump = true; - return TemplateState.InProgress; } } diff --git a/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs index f531ff9b..ed8626cc 100644 --- a/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs +++ b/MinecraftClient/Pathing/Execution/Templates/SprintJumpTemplate.cs @@ -17,16 +17,11 @@ namespace MinecraftClient.Pathing.Execution.Templates private int _tickCount; private Phase _phase = Phase.Approach; - private readonly int _distance; public SprintJumpTemplate(Location start, Location end) { ExpectedStart = start; ExpectedEnd = end; - - double dx = Math.Abs(end.X - start.X); - double dz = Math.Abs(end.Z - start.Z); - _distance = (int)Math.Round(Math.Max(dx, dz)); } public TemplateState Tick(Location pos, PlayerPhysics physics, MovementInput input) @@ -57,7 +52,6 @@ namespace MinecraftClient.Pathing.Execution.Templates case Phase.Airborne: if (!physics.OnGround) break; - // Landed _phase = Phase.Landing; goto case Phase.Landing; diff --git a/MinecraftClient/Pathing/Execution/Templates/WalkTemplate.cs b/MinecraftClient/Pathing/Execution/Templates/WalkTemplate.cs index 9c9f430c..8711d4b5 100644 --- a/MinecraftClient/Pathing/Execution/Templates/WalkTemplate.cs +++ b/MinecraftClient/Pathing/Execution/Templates/WalkTemplate.cs @@ -28,6 +28,12 @@ namespace MinecraftClient.Pathing.Execution.Templates { _tickCount++; + double dx = ExpectedEnd.X - pos.X; + double dz = ExpectedEnd.Z - pos.Z; + physics.Yaw = TemplateHelper.CalculateYaw(dx, dz); + input.Forward = true; + input.Sprint = true; + if (TemplateHelper.IsNear(pos, ExpectedEnd, horizThresholdSq: 0.20)) return TemplateState.Complete; @@ -38,13 +44,6 @@ namespace MinecraftClient.Pathing.Execution.Templates if (_stuckTicks > 40 || _tickCount > 100) return TemplateState.Failed; - double dx = ExpectedEnd.X - pos.X; - double dz = ExpectedEnd.Z - pos.Z; - physics.Yaw = TemplateHelper.CalculateYaw(dx, dz); - - input.Forward = true; - input.Sprint = true; - return TemplateState.InProgress; } }