aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0296-Add-more-line-of-sight-methods.patch
blob: f8182b74f75dc0d7443c9ad1be124162fb6cafa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: TwoLeggedCat <80929284+TwoLeggedCat@users.noreply.github.com>
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 71ef9b479888aa83455757560b60745572c7196d..cd83348de3f82b3fddcf2d4bb9187ec8173b0e40 100644
--- a/src/main/java/org/bukkit/RegionAccessor.java
+++ b/src/main/java/org/bukkit/RegionAccessor.java
@@ -437,5 +437,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 6a4c54ea92478be6e53b62ebe4e73068b9ed4a29..626eb1796d5a19d110855e2fb95cb4c761ecc544 100644
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
@@ -546,6 +546,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>