mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
feat: converge grounded path segment completion
This commit is contained in:
parent
3b4e552d70
commit
6b449cc72a
12 changed files with 489 additions and 43 deletions
|
|
@ -0,0 +1,42 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Pathing.Execution;
|
||||
using MinecraftClient.Physics;
|
||||
|
||||
namespace MinecraftClient.Tests.Pathing.Execution;
|
||||
|
||||
internal static class TemplateSimulationRunner
|
||||
{
|
||||
internal static PlayerPhysics CreateGroundedPhysics(Location start, float yaw)
|
||||
{
|
||||
return new PlayerPhysics
|
||||
{
|
||||
Position = new Vec3d(start.X, start.Y, start.Z),
|
||||
DeltaMovement = Vec3d.Zero,
|
||||
OnGround = true,
|
||||
MovementSpeed = 0.1f,
|
||||
Yaw = yaw,
|
||||
Pitch = 0f
|
||||
};
|
||||
}
|
||||
|
||||
internal static TemplateState Run(IActionTemplate template, PlayerPhysics physics, World world, int maxTicks, out Location finalPos)
|
||||
{
|
||||
var input = new MovementInput();
|
||||
TemplateState state = TemplateState.InProgress;
|
||||
|
||||
for (int tick = 0; tick < maxTicks; tick++)
|
||||
{
|
||||
input.Reset();
|
||||
Location pos = new(physics.Position.X, physics.Position.Y, physics.Position.Z);
|
||||
state = template.Tick(pos, physics, input, world);
|
||||
if (state != TemplateState.InProgress)
|
||||
break;
|
||||
|
||||
physics.ApplyInput(input);
|
||||
physics.Tick(world);
|
||||
}
|
||||
|
||||
finalPos = new Location(physics.Position.X, physics.Position.Y, physics.Position.Z);
|
||||
return state;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue