mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-10-05 19:07:32 +02:00
Better pathfinding debug
This commit is contained in:
parent
a95b339515
commit
0c139a27d4
@ -15,6 +15,7 @@ import net.citizensnpcs.util.Util;
|
|||||||
|
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
public class AStarNavigationStrategy extends AbstractPathStrategy {
|
public class AStarNavigationStrategy extends AbstractPathStrategy {
|
||||||
@ -50,6 +51,9 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
if (plan != null && Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
|
plan.debugEnd();
|
||||||
|
}
|
||||||
plan = null;
|
plan = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +65,6 @@ 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();
|
||||||
@ -76,12 +77,17 @@ public class AStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
double distance = xzDistance + dY * dY;
|
double distance = xzDistance + dY * dY;
|
||||||
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
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());
|
||||||
}
|
}
|
||||||
NMS.setDestination(npc.getEntity(), vector.getX(), vector.getY(), vector.getZ(), params.speed());
|
double destX = vector.getX(), destZ = vector.getZ();
|
||||||
|
if (npc.getEntity().getWorld().getBlockAt(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()).getType() == Material.LADDER) {
|
||||||
|
destX += 0.5;
|
||||||
|
destZ += 0.5;
|
||||||
|
}
|
||||||
|
NMS.setDestination(npc.getEntity(), destX, vector.getY(), destZ, params.speed());
|
||||||
params.run();
|
params.run();
|
||||||
plan.run(npc);
|
plan.run(npc);
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.citizensnpcs.npc.ai;
|
package net.citizensnpcs.npc.ai;
|
||||||
|
|
||||||
|
import net.citizensnpcs.Settings.Setting;
|
||||||
import net.citizensnpcs.api.ai.NavigatorParameters;
|
import net.citizensnpcs.api.ai.NavigatorParameters;
|
||||||
import net.citizensnpcs.api.ai.TargetType;
|
import net.citizensnpcs.api.ai.TargetType;
|
||||||
import net.citizensnpcs.api.ai.event.CancelReason;
|
import net.citizensnpcs.api.ai.event.CancelReason;
|
||||||
@ -36,6 +37,9 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
setCancelReason(CancelReason.STUCK);
|
setCancelReason(CancelReason.STUCK);
|
||||||
} else {
|
} else {
|
||||||
vector = plan.getCurrentVector();
|
vector = plan.getCurrentVector();
|
||||||
|
if (Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
|
plan.debug();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +50,9 @@ public class FlyingAStarNavigationStrategy extends AbstractPathStrategy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
if (plan != null && Setting.DEBUG_PATHFINDING.asBoolean()) {
|
||||||
|
plan.debugEnd();
|
||||||
|
}
|
||||||
plan = null;
|
plan = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user