diff options
Diffstat (limited to 'patches/api/0291-Add-more-line-of-sight-methods.patch')
-rw-r--r-- | patches/api/0291-Add-more-line-of-sight-methods.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/patches/api/0291-Add-more-line-of-sight-methods.patch b/patches/api/0291-Add-more-line-of-sight-methods.patch new file mode 100644 index 0000000000..dc87546ce9 --- /dev/null +++ b/patches/api/0291-Add-more-line-of-sight-methods.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: TwoLeggedCat <[email protected]> +Date: Sat, 29 May 2021 14:33:18 -0500 +Subject: [PATCH] Add more line of sight methods + + +diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java +index d8b1fa79dc24138dc71e32c14bda71c1d570ed88..b68367f123f029c3ff47eab6bfabd7a894a99da4 100644 +--- a/src/main/java/org/bukkit/RegionAccessor.java ++++ b/src/main/java/org/bukkit/RegionAccessor.java +@@ -461,5 +461,13 @@ public interface RegionAccessor extends Keyed { // Paper + @NotNull + @Override + NamespacedKey getKey(); ++ ++ /** ++ * Tell whether a line of sight exists between the given locations ++ * @param from Location to start at ++ * @param to target Location ++ * @return whether a line of sight exists between {@code from} and {@code to} ++ */ ++ public boolean lineOfSightExists(@NotNull Location from, @NotNull Location to); + // Paper end + } +diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java +index b75b79512a8fd7054f0c0c08e34f6900309e522c..62a301f2f87b053bcfbf16c9870c3f740eb70022 100644 +--- a/src/main/java/org/bukkit/entity/LivingEntity.java ++++ b/src/main/java/org/bukkit/entity/LivingEntity.java +@@ -622,6 +622,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource + */ + public boolean hasLineOfSight(@NotNull Entity other); + ++ // Paper start ++ /** ++ * Checks whether the living entity has block line of sight to the given block. ++ * <p> ++ * This uses the same algorithm that hostile mobs use to find the closest ++ * player. ++ * ++ * @param location the location to determine line of sight to ++ * @return true if there is a line of sight, false if not ++ */ ++ public boolean hasLineOfSight(@NotNull Location location); ++ // Paper end ++ + /** + * Returns if the living entity despawns when away from players or not. + * <p> |