From 97d4c3b11756876799bd2c20daac7e3516e883c5 Mon Sep 17 00:00:00 2001 From: fullwall Date: Sun, 20 Feb 2022 21:56:51 +0800 Subject: [PATCH] Make nonliving entities look at entities too, fix /npc lookclose with shulkers spamming noises --- main/src/main/java/net/citizensnpcs/trait/LookClose.java | 5 ++++- .../java/net/citizensnpcs/nms/v1_10_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_11_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java | 3 ++- .../java/net/citizensnpcs/nms/v1_18_R1/util/NMSImpl.java | 4 +++- .../main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java | 3 ++- 11 files changed, 25 insertions(+), 11 deletions(-) diff --git a/main/src/main/java/net/citizensnpcs/trait/LookClose.java b/main/src/main/java/net/citizensnpcs/trait/LookClose.java index e0bc44dee..ad7e85eaa 100644 --- a/main/src/main/java/net/citizensnpcs/trait/LookClose.java +++ b/main/src/main/java/net/citizensnpcs/trait/LookClose.java @@ -215,8 +215,11 @@ public class LookClose extends Trait implements Toggleable, CommandConfigurable return; Util.faceEntity(npc.getEntity(), lookingAt); if (npc.getEntity().getType().name().equals("SHULKER")) { - NMS.setPeekShulker(npc.getEntity(), 100 - (int) Math + boolean wasSilent = npc.getEntity().isSilent(); + npc.getEntity().setSilent(true); + NMS.setPeekShulker(npc.getEntity(), 100 - 4 * (int) Math .floor(npc.getStoredLocation().distanceSquared(lookingAt.getLocation(PLAYER_LOCATION)))); + npc.getEntity().setSilent(wasSilent); } } 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 5f2e37568..755954cc3 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 @@ -761,7 +761,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { 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 37c66b9a2..f0b817f54 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 @@ -816,7 +816,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java index 122053ffa..4de70211a 100644 --- a/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java +++ b/v1_12_R1/src/main/java/net/citizensnpcs/nms/v1_12_R1/util/NMSImpl.java @@ -824,7 +824,8 @@ public class NMSImpl implements NMSBridge { public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); BAD_CONTROLLER_LOOK.add(EntityType.SHULKER); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java index 2e33cd9d3..fc62cab8f 100644 --- a/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java +++ b/v1_13_R2/src/main/java/net/citizensnpcs/nms/v1_13_R2/util/NMSImpl.java @@ -859,7 +859,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java index 23ce548a2..27c90f425 100644 --- a/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java +++ b/v1_14_R1/src/main/java/net/citizensnpcs/nms/v1_14_R1/util/NMSImpl.java @@ -927,7 +927,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java index 5c04c140a..9a3a5ba90 100644 --- a/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java +++ b/v1_15_R1/src/main/java/net/citizensnpcs/nms/v1_15_R1/util/NMSImpl.java @@ -939,7 +939,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java index ed42c6c46..2efa3ebb4 100644 --- a/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java +++ b/v1_16_R3/src/main/java/net/citizensnpcs/nms/v1_16_R3/util/NMSImpl.java @@ -959,7 +959,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java index 97a211f1e..d2ae1f27e 100644 --- a/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java +++ b/v1_17_R1/src/main/java/net/citizensnpcs/nms/v1_17_R1/util/NMSImpl.java @@ -963,7 +963,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof Mob) && !(handle instanceof EntityHumanNPC))) { if (to instanceof org.bukkit.entity.LivingEntity) { look(from, ((org.bukkit.entity.LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_18_R1/src/main/java/net/citizensnpcs/nms/v1_18_R1/util/NMSImpl.java b/v1_18_R1/src/main/java/net/citizensnpcs/nms/v1_18_R1/util/NMSImpl.java index 37bd28cc2..c4393c052 100644 --- a/v1_18_R1/src/main/java/net/citizensnpcs/nms/v1_18_R1/util/NMSImpl.java +++ b/v1_18_R1/src/main/java/net/citizensnpcs/nms/v1_18_R1/util/NMSImpl.java @@ -966,7 +966,9 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof Mob) && !(handle instanceof EntityHumanNPC))) { if (to instanceof org.bukkit.entity.LivingEntity) { look(from, ((org.bukkit.entity.LivingEntity) to).getEyeLocation(), false, true); } else { diff --git a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java index b02ac9407..84a2b80a6 100644 --- a/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java +++ b/v1_8_R3/src/main/java/net/citizensnpcs/nms/v1_8_R3/util/NMSImpl.java @@ -693,7 +693,8 @@ public class NMSImpl implements NMSBridge { @Override public void look(org.bukkit.entity.Entity from, org.bukkit.entity.Entity to) { Entity handle = NMSImpl.getHandle(from), target = NMSImpl.getHandle(to); - if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType())) { + if (BAD_CONTROLLER_LOOK.contains(handle.getBukkitEntity().getType()) + || (!(handle instanceof EntityInsentient) && !(handle instanceof EntityHumanNPC))) { if (to instanceof LivingEntity) { look(from, ((LivingEntity) to).getEyeLocation(), false, true); } else {