mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-29 13:04:59 +00:00
feat: tighten parkour reliability checks
This commit is contained in:
parent
6b449cc72a
commit
0e0fc06b72
7 changed files with 987 additions and 25 deletions
|
|
@ -0,0 +1,95 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Pathing.Core;
|
||||
using MinecraftClient.Pathing.Execution;
|
||||
using MinecraftClient.Pathing.Execution.Templates;
|
||||
using Xunit;
|
||||
|
||||
namespace MinecraftClient.Tests.Pathing.Execution;
|
||||
|
||||
public sealed class SprintJumpTemplateScenarioTests
|
||||
{
|
||||
[Fact]
|
||||
public void SprintJumpTemplate_TwoBlockGap_FinalStop_Completes()
|
||||
{
|
||||
World world = FlatWorldTestBuilder.CreateStoneFloor(min: 0, max: 16);
|
||||
FlatWorldTestBuilder.ClearBox(world, 0, 79, 0, 4, 82, 1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, 79, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, 79, 0);
|
||||
|
||||
var segment = new PathSegment
|
||||
{
|
||||
Start = new Location(0.5, 80, 0.5),
|
||||
End = new Location(2.5, 80, 0.5),
|
||||
MoveType = MoveType.Parkour,
|
||||
ExitTransition = PathTransitionType.FinalStop
|
||||
};
|
||||
|
||||
var template = new SprintJumpTemplate(segment, null);
|
||||
var physics = TemplateSimulationRunner.CreateGroundedPhysics(segment.Start, yaw: 270f);
|
||||
|
||||
TemplateState state = TemplateSimulationRunner.Run(template, physics, world, maxTicks: 140, out Location finalPos);
|
||||
|
||||
Assert.True(state == TemplateState.Complete, $"state={state} finalPos={finalPos} vel={physics.DeltaMovement}");
|
||||
Assert.True(TemplateFootingHelper.IsFootprintInsideTargetBlock(finalPos, segment.End));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SprintJumpTemplate_ThreeBlockGap_FinalStop_Completes()
|
||||
{
|
||||
World world = FlatWorldTestBuilder.CreateStoneFloor(min: 0, max: 16);
|
||||
FlatWorldTestBuilder.ClearBox(world, 0, 79, 0, 5, 82, 1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, 79, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 3, 79, 0);
|
||||
|
||||
var segment = new PathSegment
|
||||
{
|
||||
Start = new Location(0.5, 80, 0.5),
|
||||
End = new Location(3.5, 80, 0.5),
|
||||
MoveType = MoveType.Parkour,
|
||||
ExitTransition = PathTransitionType.FinalStop
|
||||
};
|
||||
|
||||
var template = new SprintJumpTemplate(segment, null);
|
||||
var physics = TemplateSimulationRunner.CreateGroundedPhysics(segment.Start, yaw: 270f);
|
||||
|
||||
TemplateState state = TemplateSimulationRunner.Run(template, physics, world, maxTicks: 140, out Location finalPos);
|
||||
|
||||
Assert.True(state == TemplateState.Complete, $"state={state} finalPos={finalPos} vel={physics.DeltaMovement}");
|
||||
Assert.True(TemplateFootingHelper.IsFootprintInsideTargetBlock(finalPos, segment.End));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SprintJumpTemplate_TwoBlockGap_LandingRecovery_CompletesInsideLandingBlock()
|
||||
{
|
||||
World world = FlatWorldTestBuilder.CreateStoneFloor(min: 0, max: 16);
|
||||
FlatWorldTestBuilder.ClearBox(world, 0, 79, 0, 4, 82, 2);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, 79, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, 79, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, 79, 1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, 80, 1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, 81, 1);
|
||||
|
||||
var segment = new PathSegment
|
||||
{
|
||||
Start = new Location(0.5, 80, 0.5),
|
||||
End = new Location(2.5, 80, 0.5),
|
||||
MoveType = MoveType.Parkour,
|
||||
ExitTransition = PathTransitionType.LandingRecovery
|
||||
};
|
||||
var next = new PathSegment
|
||||
{
|
||||
Start = new Location(2.5, 80, 0.5),
|
||||
End = new Location(2.5, 80, 1.5),
|
||||
MoveType = MoveType.Traverse,
|
||||
ExitTransition = PathTransitionType.FinalStop
|
||||
};
|
||||
|
||||
var template = new SprintJumpTemplate(segment, next);
|
||||
var physics = TemplateSimulationRunner.CreateGroundedPhysics(segment.Start, yaw: 270f);
|
||||
|
||||
TemplateState state = TemplateSimulationRunner.Run(template, physics, world, maxTicks: 140, out Location finalPos);
|
||||
|
||||
Assert.True(state == TemplateState.Complete, $"state={state} finalPos={finalPos} vel={physics.DeltaMovement}");
|
||||
Assert.True(TemplateFootingHelper.IsFootprintInsideTargetBlock(finalPos, segment.End));
|
||||
}
|
||||
}
|
||||
93
MinecraftClient.Tests/Pathing/Moves/MoveParkourTests.cs
Normal file
93
MinecraftClient.Tests/Pathing/Moves/MoveParkourTests.cs
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Pathing.Core;
|
||||
using MinecraftClient.Pathing.Moves.Impl;
|
||||
using MinecraftClient.Tests.Pathing.Execution;
|
||||
using Xunit;
|
||||
|
||||
namespace MinecraftClient.Tests.Pathing.Moves;
|
||||
|
||||
public sealed class MoveParkourTests
|
||||
{
|
||||
private const int FloorY = 79;
|
||||
|
||||
private static CalculationContext BuildContext(World world)
|
||||
=> new(world, allowParkour: true, allowParkourAscend: true);
|
||||
|
||||
[Fact]
|
||||
public void Rejects3x1JumpWhenRunUpMissing()
|
||||
{
|
||||
var world = FlatWorldTestBuilder.CreateStoneFloor(FloorY);
|
||||
world.SetBlock(new Location(-1, FloorY, 0), Block.Air);
|
||||
var ctx = BuildContext(world);
|
||||
var move = new MoveParkour(3, 0);
|
||||
var result = default(MoveResult);
|
||||
|
||||
move.Calculate(ctx, 0, FloorY + 1, 0, ref result);
|
||||
|
||||
Assert.True(result.IsImpossible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Accepts2x1GapWithClearTakeoff()
|
||||
{
|
||||
var world = FlatWorldTestBuilder.CreateStoneFloor(FloorY);
|
||||
world.SetBlock(new Location(1, FloorY, 0), Block.Air);
|
||||
var ctx = BuildContext(world);
|
||||
var move = new MoveParkour(2, 0);
|
||||
var result = default(MoveResult);
|
||||
|
||||
move.Calculate(ctx, 0, FloorY + 1, 0, ref result);
|
||||
|
||||
Assert.False(result.IsImpossible);
|
||||
Assert.Equal(2, result.DestX);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rejects2x1WhenAdjacentBlockIsStillWalkable()
|
||||
{
|
||||
var world = FlatWorldTestBuilder.CreateStoneFloor(FloorY);
|
||||
var ctx = BuildContext(world);
|
||||
var move = new MoveParkour(2, 0);
|
||||
var result = default(MoveResult);
|
||||
|
||||
move.Calculate(ctx, 0, FloorY + 1, 0, ref result);
|
||||
|
||||
Assert.True(result.IsImpossible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Rejects2x1GapWhenSideWallNarrowsLanding()
|
||||
{
|
||||
var world = FlatWorldTestBuilder.CreateStoneFloor(FloorY);
|
||||
FlatWorldTestBuilder.ClearBox(world, -1, FloorY, -2, 4, FloorY + 4, 2);
|
||||
FlatWorldTestBuilder.SetSolid(world, 0, FloorY, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, FloorY, 0);
|
||||
FlatWorldTestBuilder.SetSolid(world, 1, FloorY + 1, -1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 1, FloorY + 2, -1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, FloorY + 1, -1);
|
||||
FlatWorldTestBuilder.SetSolid(world, 2, FloorY + 2, -1);
|
||||
|
||||
var ctx = BuildContext(world);
|
||||
var move = new MoveParkour(2, 0);
|
||||
var result = default(MoveResult);
|
||||
|
||||
move.Calculate(ctx, 0, FloorY + 1, 0, ref result);
|
||||
|
||||
Assert.True(result.IsImpossible);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RejectsDiagonalWhenShoulderBlocked()
|
||||
{
|
||||
var world = FlatWorldTestBuilder.CreateStoneFloor(FloorY);
|
||||
world.SetBlock(new Location(1, FloorY + 1, 0), new Block(1));
|
||||
world.SetBlock(new Location(1, FloorY + 2, 0), new Block(1));
|
||||
var ctx = BuildContext(world);
|
||||
var move = new MoveParkour(1, 1);
|
||||
var result = default(MoveResult);
|
||||
|
||||
move.Calculate(ctx, 0, FloorY + 1, 0, ref result);
|
||||
|
||||
Assert.True(result.IsImpossible);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue