From 23a8e4efe3aae4d4a2aff0351380e9f8e4ec2f13 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Wed, 21 Mar 2012 16:30:35 +0100 Subject: [PATCH] Add LivingEntity.hasLineOfSight. Addresses BUKKIT-1255 By: TomyLobo --- .../src/main/java/org/bukkit/entity/LivingEntity.java | 9 +++++++++ .../java/org/bukkit/plugin/messaging/TestPlayer.java | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 6787d79a55..e93453a394 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -269,4 +269,13 @@ public interface LivingEntity extends Entity { * @return A collection of {@link PotionEffect}s */ public Collection getActivePotionEffects(); + + /** + * Checks whether the entity has block line of sight to another.
+ * This uses the same algorithm that hostile mobs use to find the closest player. + * + * @param other The entity to determine line of sight to. + * @return true if there is a line of sight, false if not. + */ + public boolean hasLineOfSight(Entity other); } diff --git a/paper-api/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java b/paper-api/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java index 4a4032b6e6..15e60c14b3 100644 --- a/paper-api/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java +++ b/paper-api/src/test/java/org/bukkit/plugin/messaging/TestPlayer.java @@ -756,4 +756,8 @@ public class TestPlayer implements Player { public boolean isBlocking() { throw new UnsupportedOperationException("Not supported yet."); } + + public boolean hasLineOfSight(Entity other) { + throw new UnsupportedOperationException("Not supported yet."); + } }