From a0c6039e8e5757f2f59afeb872f8320d3e69eaca Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 20 Oct 2013 18:52:57 +0800 Subject: [PATCH] Add debug-pathfinding setting --- src/main/java/net/citizensnpcs/Settings.java | 1 + .../net/citizensnpcs/npc/ai/AStarNavigationStrategy.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/net/citizensnpcs/Settings.java b/src/main/java/net/citizensnpcs/Settings.java index 8f2171b21..7a510010a 100644 --- a/src/main/java/net/citizensnpcs/Settings.java +++ b/src/main/java/net/citizensnpcs/Settings.java @@ -68,6 +68,7 @@ public class Settings { DATABASE_URL("storage.database.url", ""), DATABASE_USERNAME("storage.database.username", ""), DEBUG_MODE("general.debug-mode", false), + DEBUG_PATHFINDING("general.debug-mode.pathfinding", false), DEFAULT_LOOK_CLOSE("npc.default.look-close.enabled", false), DEFAULT_LOOK_CLOSE_RANGE("npc.default.look-close.range", 5), DEFAULT_NPC_LIMIT("npc.limits.default-limit", 10), diff --git a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java index 471233b04..10b245924 100644 --- a/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java +++ b/src/main/java/net/citizensnpcs/npc/ai/AStarNavigationStrategy.java @@ -1,5 +1,6 @@ package net.citizensnpcs.npc.ai; +import net.citizensnpcs.Settings.Setting; import net.citizensnpcs.api.ai.NavigatorParameters; import net.citizensnpcs.api.ai.TargetType; import net.citizensnpcs.api.ai.event.CancelReason; @@ -12,6 +13,7 @@ import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.util.NMS; import net.minecraft.server.v1_6_R3.EntityLiving; +import org.bukkit.Effect; import org.bukkit.Location; import org.bukkit.util.Vector; @@ -66,6 +68,11 @@ public class AStarNavigationStrategy extends AbstractPathStrategy { double dY = vector.getY() - handle.locY; double xzDistance = dX * dX + dZ * dZ; double distance = xzDistance + dY * dY; + if (Setting.DEBUG_PATHFINDING.asBoolean()) { + for (int i = 0; i < 5; i++) { + npc.getBukkitEntity().getWorld().playEffect(npc.getStoredLocation(), Effect.MOBSPAWNER_FLAMES, 0); + } + } if (distance > 0 && dY > 0 && xzDistance <= 2.75) { NMS.setShouldJump(npc.getBukkitEntity()); }