mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-12-28 20:17:50 +01:00
Use new parameter and debug
This commit is contained in:
parent
66a07f8f05
commit
a95b339515
@ -30,12 +30,16 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
this.destination = dest;
|
this.destination = dest;
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
Location location = Util.getEyeLocation(npc.getEntity());
|
Location location = Util.getEyeLocation(npc.getEntity());
|
||||||
plan = ASTAR.runFully(new VectorGoal(dest, (float) params.distanceMargin()), new VectorNode(location,
|
VectorGoal goal = new VectorGoal(dest, (float) params.pathDistanceMargin());
|
||||||
new ChunkBlockSource(location, params.range()), params.examiners()), 50000);
|
plan = ASTAR.runFully(goal, new VectorNode(goal, location, new ChunkBlockSource(location, params.range()),
|
||||||
|
params.examiners()), 50000);
|
||||||
if (plan == null || plan.isComplete()) {
|
if (plan == null || plan.isComplete()) {
|
||||||
setCancelReason(CancelReason.STUCK);
|
setCancelReason(CancelReason.STUCK);
|
||||||
} else {
|
} else {
|
||||||
vector = plan.getCurrentVector();
|
vector = plan.getCurrentVector();
|
||||||
|
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
|
plan.debug();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +61,9 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
if (npc.getEntity().getLocation(NPC_LOCATION).toVector().distanceSquared(vector) <= params.distanceMargin()) {
|
if (npc.getEntity().getLocation(NPC_LOCATION).toVector().distanceSquared(vector) <= params.distanceMargin()) {
|
||||||
plan.update(npc);
|
plan.update(npc);
|
||||||
if (plan.isComplete()) {
|
if (plan.isComplete()) {
|
||||||
|
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
|
plan.debugEnd();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vector = plan.getCurrentVector();
|
vector = plan.getCurrentVector();
|
||||||
@ -68,10 +75,8 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
double xzDistance = dX * dX + dZ * dZ;
|
double xzDistance = dX * dX + dZ * dZ;
|
||||||
double distance = xzDistance + dY * dY;
|
double distance = xzDistance + dY * dY;
|
||||||
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
for (int i = 0; i < 3; i++) {
|
npc.getEntity().getWorld()
|
||||||
npc.getEntity().getWorld()
|
.playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL, 0);
|
||||||
.playEffect(vector.toLocation(npc.getEntity().getWorld()), Effect.ENDER_SIGNAL, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (distance > 0 && dY > 0 && dY < 1 && xzDistance <= 2.75) {
|
if (distance > 0 && dY > 0 && dY < 1 && xzDistance <= 2.75) {
|
||||||
NMS.setShouldJump(npc.getEntity());
|
NMS.setShouldJump(npc.getEntity());
|
||||||
|
@ -29,8 +29,9 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
this.parameters = params;
|
this.parameters = params;
|
||||||
this.npc = npc;
|
this.npc = npc;
|
||||||
Location location = Util.getEyeLocation(npc.getEntity());
|
Location location = Util.getEyeLocation(npc.getEntity());
|
||||||
plan = ASTAR.runFully(new VectorGoal(dest, (float) params.distanceMargin()), new VectorNode(location,
|
VectorGoal goal = new VectorGoal(dest, (float) params.pathDistanceMargin());
|
||||||
new ChunkBlockSource(location, params.range()), params.examiners()), 50000);
|
plan = ASTAR.runFully(goal, new VectorNode(goal, location, new ChunkBlockSource(location, params.range()),
|
||||||
|
params.examiners()), 50000);
|
||||||
if (plan == null || plan.isComplete()) {
|
if (plan == null || plan.isComplete()) {
|
||||||
setCancelReason(CancelReason.STUCK);
|
setCancelReason(CancelReason.STUCK);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user