From ac02ffb91781a062ba7cca4cd04d0be97eadf5db Mon Sep 17 00:00:00 2001 From: mcmonkey Date: Sat, 16 Mar 2019 19:56:40 -0700 Subject: [PATCH] fix guarding pathing --- src/main/java/org/mcmonkey/sentinel/SentinelTrait.java | 10 +++++++--- .../java/org/mcmonkey/sentinel/SentinelUtilities.java | 2 +- .../sentinel/commands/SentinelInfoCommands.java | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java b/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java index 9156a8a..8fb3f7c 100644 --- a/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java +++ b/src/main/java/org/mcmonkey/sentinel/SentinelTrait.java @@ -1100,7 +1100,11 @@ else if (chasing == null) { npc.getNavigator().getDefaultParameters().distanceMargin(SentinelPlugin.instance.guardDistanceMargin); npc.getNavigator().getDefaultParameters().range(100); npc.getNavigator().getDefaultParameters().stuckAction(TeleportStuckAction.INSTANCE); - npc.getNavigator().setTarget(SentinelUtilities.pickNear(player.getLocation(), guardSelectionRange)); + Location picked = SentinelUtilities.pickNear(player.getLocation(), guardSelectionRange); + if (SentinelPlugin.debugMe) { + debug("Guard movement chosen to go to " + picked.toVector().toBlockVector().toString()); + } + npc.getNavigator().setTarget(picked); npc.getNavigator().getLocalParameters().speedModifier((float) speed); chased = true; } @@ -1131,7 +1135,7 @@ else if (chasing == null) { chased = false; } else { - if (pathingTo == null && npc.getNavigator().isNavigating()) { + if (pathingTo == null && npc.getNavigator().isNavigating() && getGuarding() == null) { npc.getNavigator().cancelNavigation(); needsSafeReturn = false; } @@ -1142,7 +1146,7 @@ else if (chasing == null) { } } } - else if (chasing == null && pathingTo == null && npc.getNavigator().isNavigating() && needsSafeReturn) { + else if (chasing == null && getGuarding() == null && pathingTo == null && npc.getNavigator().isNavigating() && needsSafeReturn) { npc.getNavigator().cancelNavigation(); needsSafeReturn = false; } diff --git a/src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java b/src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java index 6ae9876..4943700 100644 --- a/src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java +++ b/src/main/java/org/mcmonkey/sentinel/SentinelUtilities.java @@ -73,7 +73,7 @@ public static Location rayTrace(Location start, Location end) { */ public static Location pickNear(Location start, double range) { Location hit = rayTrace(start.clone().add(0, 1.5, 0), start.clone().add( - SentinelUtilities.randomDecimal(-range, range), 1.5, SentinelUtilities.randomDecimal(range, range))); + SentinelUtilities.randomDecimal(-range, range), 1.5, SentinelUtilities.randomDecimal(-range, range))); if (hit.subtract(0, 1, 0).getBlock().getType().isSolid()) { return hit; } diff --git a/src/main/java/org/mcmonkey/sentinel/commands/SentinelInfoCommands.java b/src/main/java/org/mcmonkey/sentinel/commands/SentinelInfoCommands.java index 2b8859c..4cc8dfe 100644 --- a/src/main/java/org/mcmonkey/sentinel/commands/SentinelInfoCommands.java +++ b/src/main/java/org/mcmonkey/sentinel/commands/SentinelInfoCommands.java @@ -47,7 +47,7 @@ public void info(CommandContext args, CommandSender sender, SentinelTrait sentin @Command(aliases = {"sentinel"}, usage = "stats", desc = "Shows statistics about the current NPC.", - modifiers = {"stats"}, permission = "sentinel.info", min = 2, max = 2) + modifiers = {"stats"}, permission = "sentinel.info", min = 1, max = 1) @Requirements(livingEntity = true, ownership = true, traits = {SentinelTrait.class}) public void stats(CommandContext args, CommandSender sender, SentinelTrait sentinel) { sender.sendMessage(SentinelCommand.prefixGood + ChatColor.RESET + sentinel.getNPC().getFullName() + SentinelCommand.ColorBasic