diff --git a/dist/src/main/assembly/all-jar.xml b/dist/src/main/assembly/all-jar.xml
index d60accf82..487f4a1ad 100644
--- a/dist/src/main/assembly/all-jar.xml
+++ b/dist/src/main/assembly/all-jar.xml
@@ -6,7 +6,6 @@
jar
-
false
diff --git a/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java b/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java
index aa7bbdfa7..72fecfdb3 100644
--- a/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java
+++ b/main/src/main/java/net/citizensnpcs/npc/ai/CitizensNavigator.java
@@ -37,6 +37,7 @@ import net.citizensnpcs.api.astar.pathfinder.PathPoint.PathCallback;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.util.DataKey;
import net.citizensnpcs.util.NMS;
+import net.citizensnpcs.util.Util;
public class CitizensNavigator implements Navigator, Runnable {
private final NavigatorParameters defaultParams = new NavigatorParameters().baseSpeed(UNINITIALISED_SPEED)
@@ -152,6 +153,9 @@ public class CitizensNavigator implements Navigator, Runnable {
updatePathfindingRange();
boolean finished = executing.update();
+ if (localParams.lookAtFunction() != null) {
+ Util.faceLocation(npc.getEntity(), localParams.lookAtFunction().apply(this), true);
+ }
if (!finished) {
return;
}
diff --git a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java
index f23500121..053d9c756 100644
--- a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java
+++ b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetchThread.java
@@ -56,16 +56,15 @@ class ProfileFetchThread implements Runnable {
queue.add(request);
requested.put(name, request);
return;
- }
- else if (request.getResult() == ProfileFetchResult.TOO_MANY_REQUESTS) {
+ } else if (request.getResult() == ProfileFetchResult.TOO_MANY_REQUESTS) {
queue.add(request);
}
}
if (handler != null) {
- if (request.getResult() == ProfileFetchResult.PENDING ||
- request.getResult() == ProfileFetchResult.TOO_MANY_REQUESTS) {
+ if (request.getResult() == ProfileFetchResult.PENDING
+ || request.getResult() == ProfileFetchResult.TOO_MANY_REQUESTS) {
addHandler(request, handler);
} else {
sendResult(handler, request);
diff --git a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetcher.java b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetcher.java
index 68983f860..881478b2d 100644
--- a/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetcher.java
+++ b/main/src/main/java/net/citizensnpcs/npc/profile/ProfileFetcher.java
@@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
import com.mojang.authlib.Agent;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.GameProfileRepository;
@@ -41,8 +42,7 @@ public class ProfileFetcher {
int i = 0;
for (ProfileRequest request : requests) {
- playerNames[i] = request.getPlayerName();
- i++;
+ playerNames[i++] = request.getPlayerName();
}
repo.findProfilesByNames(playerNames, Agent.MINECRAFT, new ProfileLookupCallback() {
@@ -50,7 +50,8 @@ public class ProfileFetcher {
public void onProfileLookupFailed(GameProfile profile, Exception e) {
if (Messaging.isDebugging()) {
Messaging.debug(
- "Profile lookup for player '" + profile.getName() + "' failed: " + getExceptionMsg(e));
+ "Profile lookup for player '" + profile.getName() + "' failed2: " + getExceptionMsg(e));
+ Messaging.debug(Throwables.getStackTraceAsString(e));
}
ProfileRequest request = findRequest(profile.getName(), requests);
@@ -76,12 +77,13 @@ public class ProfileFetcher {
if (request == null)
return;
- try {
+ try {
request.setResult(NMS.fillProfileProperties(profile, true), ProfileFetchResult.SUCCESS);
} catch (Exception e) {
if (Messaging.isDebugging()) {
Messaging.debug(
- "Profile lookup for player '" + profile.getName() + "' failed: " + getExceptionMsg(e));
+ "Profile lookup for player '" + profile.getName() + "' failed2: " + getExceptionMsg(e));
+ Messaging.debug(Throwables.getStackTraceAsString(e));
}
if (isTooManyRequests(e)) {
@@ -124,9 +126,7 @@ public class ProfileFetcher {
}
private static String getExceptionMsg(Exception e) {
- String message = e.getMessage();
- String cause = e.getCause() != null ? e.getCause().getMessage() : null;
- return cause != null ? cause : message;
+ return Throwables.getRootCause(e).getMessage();
}
private static void initThread() {
diff --git a/main/src/main/java/net/citizensnpcs/util/Util.java b/main/src/main/java/net/citizensnpcs/util/Util.java
index e2e6646cb..8d07bb638 100644
--- a/main/src/main/java/net/citizensnpcs/util/Util.java
+++ b/main/src/main/java/net/citizensnpcs/util/Util.java
@@ -23,17 +23,6 @@ public class Util {
private Util() {
}
- public static float clampYaw(float yaw) {
- while (yaw < -180.0F) {
- yaw += 360.0F;
- }
-
- while (yaw >= 180.0F) {
- yaw -= 360.0F;
- }
- return yaw;
- }
-
public static void assumePose(Entity entity, float yaw, float pitch) {
NMS.look(entity, yaw, pitch);
}
@@ -51,14 +40,29 @@ public class Util {
return event;
}
+ public static float clampYaw(float yaw) {
+ while (yaw < -180.0F) {
+ yaw += 360.0F;
+ }
+
+ while (yaw >= 180.0F) {
+ yaw -= 360.0F;
+ }
+ return yaw;
+ }
+
public static void faceEntity(Entity entity, Entity at) {
- if (entity.getWorld() != at.getWorld())
+ if (at == null || entity == null || entity.getWorld() != at.getWorld())
return;
faceLocation(entity, at.getLocation(AT_LOCATION));
}
public static void faceLocation(Entity entity, Location to) {
- if (entity.getWorld() != to.getWorld())
+ faceLocation(entity, to, false);
+ }
+
+ public static void faceLocation(Entity entity, Location to, boolean headOnly) {
+ if (to == null || entity.getWorld() != to.getWorld())
return;
Location fromLocation = entity.getLocation(FROM_LOCATION);
double xDiff, yDiff, zDiff;
@@ -74,7 +78,11 @@ public class Util {
if (zDiff < 0.0)
yaw += Math.abs(180 - yaw) * 2;
- NMS.look(entity, (float) yaw - 90, (float) pitch);
+ if (headOnly) {
+ NMS.setHeadYaw(entity, (float) yaw - 90);
+ } else {
+ NMS.look(entity, (float) yaw - 90, (float) pitch);
+ }
}
public static Location getEyeLocation(Entity entity) {
diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java
index 45ada5a74..0c984ec8c 100644
--- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java
+++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java
@@ -471,8 +471,7 @@ public class NMSImpl implements NMSBridge {
public TargetNavigator getTargetNavigator(org.bukkit.entity.Entity entity, org.bukkit.entity.Entity target,
NavigatorParameters parameters) {
NavigationAbstract navigation = getNavigation(entity);
- return navigation == null ? null
- : new NavigationFieldWrapper(navigation, target, parameters);
+ return navigation == null ? null : new NavigationFieldWrapper(navigation, target, parameters);
}
@Override