diff --git a/main/src/main/java/net/citizensnpcs/util/NMS.java b/main/src/main/java/net/citizensnpcs/util/NMS.java index fa230ddba..b3aa3667b 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMS.java +++ b/main/src/main/java/net/citizensnpcs/util/NMS.java @@ -156,8 +156,8 @@ public class NMS { BRIDGE.look(entity, yaw, pitch); } - public static void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) { - BRIDGE.look(entity, to, headOnly); + public static void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) { + BRIDGE.look(entity, to, headOnly, immediate); } public static void look(org.bukkit.entity.Entity bhandle, org.bukkit.entity.Entity btarget) { diff --git a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java index 31f6bb53d..8a7793b7f 100644 --- a/main/src/main/java/net/citizensnpcs/util/NMSBridge.java +++ b/main/src/main/java/net/citizensnpcs/util/NMSBridge.java @@ -82,7 +82,7 @@ public interface NMSBridge { public void look(Entity entity, float yaw, float pitch); - public void look(Entity entity, Location to, boolean headOnly); + public void look(Entity entity, Location to, boolean headOnly, boolean immediate); public void mount(Entity entity, Entity passenger); diff --git a/main/src/main/java/net/citizensnpcs/util/Util.java b/main/src/main/java/net/citizensnpcs/util/Util.java index 21f72a480..bcaac4112 100644 --- a/main/src/main/java/net/citizensnpcs/util/Util.java +++ b/main/src/main/java/net/citizensnpcs/util/Util.java @@ -66,9 +66,13 @@ public class Util { } public static void faceLocation(Entity entity, Location to, boolean headOnly) { + faceLocation(entity, to, headOnly, true); + } + + public static void faceLocation(Entity entity, Location to, boolean headOnly, boolean immediate) { if (to == null || entity.getWorld() != to.getWorld()) return; - NMS.look(entity, to, headOnly); + NMS.look(entity, to, headOnly, immediate); } public static Location getEyeLocation(Entity entity) { diff --git a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java index 10db47202..0cc7f5aae 100644 --- a/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java +++ b/v1_10_R1/src/main/java/net/citizensnpcs/nms/v1_10_R1/entity/EntityHumanNPC.java @@ -383,7 +383,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), target.getYaw(), target.getPitch()); + controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); } public void updateAI() { 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 190e39556..418808207 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 @@ -605,9 +605,9 @@ public class NMSImpl implements NMSBridge { } @Override - public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) { + public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) { Entity handle = NMSImpl.getHandle(entity); - if (headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { Location fromLocation = entity.getLocation(FROM_LOCATION); double xDiff, yDiff, zDiff; @@ -635,8 +635,8 @@ public class NMSImpl implements NMSBridge { return; } if (handle instanceof EntityInsentient) { - ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), to.getYaw(), - to.getPitch()); + ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), + ((EntityInsentient) handle).cJ(), ((EntityInsentient) handle).N()); while (((EntityInsentient) handle).aQ >= 180F) { ((EntityInsentient) handle).aQ -= 360F; } @@ -653,9 +653,9 @@ public class NMSImpl implements NMSBridge { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { if (to instanceof LivingEntity) { - look(from, ((LivingEntity) to).getEyeLocation(), false); + look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { - look(from, to.getLocation(), false); + look(from, to.getLocation(), false, true); } } else if (handle instanceof EntityInsentient) { ((EntityInsentient) handle).getControllerLook().a(target, ((EntityInsentient) handle).cJ(), @@ -1390,9 +1390,9 @@ public class NMSImpl implements NMSBridge { navigation.l(); } - private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE, - EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE, - EntityType.GHAST); + private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH, + EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, + EntityType.HORSE, EntityType.GHAST); private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle"); private static final float DEFAULT_SPEED = 1F; diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java index 52cc21933..14356dda7 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/entity/EntityHumanNPC.java @@ -394,7 +394,7 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder, Skinnable } public void setTargetLook(Location target) { - controllerLook.a(target.getX(), target.getY(), target.getZ(), target.getYaw(), target.getPitch()); + controllerLook.a(target.getX(), target.getY(), target.getZ(), 10, 40); } public void updateAI() { diff --git a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java index 0c12413ce..b54224a3a 100644 --- a/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java +++ b/v1_11_R1/src/main/java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java @@ -637,9 +637,9 @@ public class NMSImpl implements NMSBridge { } @Override - public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly) { + public void look(org.bukkit.entity.Entity entity, Location to, boolean headOnly, boolean immediate) { Entity handle = NMSImpl.getHandle(entity); - if (headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + if (immediate || headOnly || BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { Location fromLocation = entity.getLocation(FROM_LOCATION); double xDiff, yDiff, zDiff; @@ -667,8 +667,8 @@ public class NMSImpl implements NMSBridge { return; } if (handle instanceof EntityInsentient) { - ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), to.getYaw(), - to.getPitch()); + ((EntityInsentient) handle).getControllerLook().a(to.getX(), to.getY(), to.getZ(), + ((EntityInsentient) handle).cL(), ((EntityInsentient) handle).N()); while (((EntityLiving) handle).aP >= 180F) { ((EntityLiving) handle).aP -= 360F; @@ -686,9 +686,9 @@ public class NMSImpl implements NMSBridge { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { if (to instanceof LivingEntity) { - look(from, ((LivingEntity) to).getEyeLocation(), false); + look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { - look(from, to.getLocation(), false); + look(from, to.getLocation(), false, true); } } else if (handle instanceof EntityInsentient) { ((EntityInsentient) handle).getControllerLook().a(target, ((EntityInsentient) handle).cL(), @@ -1434,9 +1434,9 @@ public class NMSImpl implements NMSBridge { navigation.l(); } - private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.SILVERFISH, EntityType.ENDERMITE, - EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, EntityType.HORSE, - EntityType.GHAST); + private static final Set BAD_CONTROLLER_LOOK = EnumSet.of(EntityType.POLAR_BEAR, EntityType.SILVERFISH, + EntityType.ENDERMITE, EntityType.ENDER_DRAGON, EntityType.BAT, EntityType.SLIME, EntityType.MAGMA_CUBE, + EntityType.HORSE, EntityType.GHAST); private static final Field CRAFT_BOSSBAR_HANDLE_FIELD = NMS.getField(CraftBossBar.class, "handle"); private static final float DEFAULT_SPEED = 1F; private static final Field ENDERDRAGON_BATTLE_BAR_FIELD = NMS.getField(EnderDragonBattle.class, "c");