2021-06-11 14:02:28 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
|
2022-06-05 22:51:44 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java
|
2023-09-23 04:06:03 +02:00
|
|
|
index 58b81f30f9e29ab481ae96c7eea40ad976a4b192..63503cf17847a85264c930a9fc23a5aab5955c3c 100644
|
2022-06-05 22:51:44 +02:00
|
|
|
--- a/src/main/java/org/bukkit/RegionAccessor.java
|
|
|
|
+++ b/src/main/java/org/bukkit/RegionAccessor.java
|
2023-05-12 13:10:08 +02:00
|
|
|
@@ -437,5 +437,13 @@ public interface RegionAccessor extends Keyed { // Paper
|
2021-06-11 14:02:28 +02:00
|
|
|
@NotNull
|
2022-06-05 22:51:44 +02:00
|
|
|
@Override
|
|
|
|
NamespacedKey getKey();
|
2021-06-11 14:02:28 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 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
|
2022-06-05 22:51:44 +02:00
|
|
|
}
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java
|
2023-09-21 21:54:46 +02:00
|
|
|
index 9763cf4720e1278061e3ba139b824147e9540945..b665b99ca6de3a35c3296a500db1527a8513a711 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/LivingEntity.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/LivingEntity.java
|
2023-07-04 10:22:56 +02:00
|
|
|
@@ -570,6 +570,19 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
|
|
|
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>
|