mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-01 00:10:32 +01:00
Expose canReach to mob pathfinding API
This commit is contained in:
parent
3e0eb4a1ba
commit
c70d8db06e
@ -13,10 +13,10 @@ You can use EntityPathfindEvent to cancel new pathfinds from overriding your cur
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..43f062257472a06e9e64c2feef6c3b1012aee00e
|
index 0000000000000000000000000000000000000000..3c1e2c93d923a683cc0455af77c43784ef12270e
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
+++ b/src/main/java/com/destroystokyo/paper/entity/Pathfinder.java
|
||||||
@@ -0,0 +1,212 @@
|
@@ -0,0 +1,220 @@
|
||||||
+package com.destroystokyo.paper.entity;
|
+package com.destroystokyo.paper.entity;
|
||||||
+
|
+
|
||||||
+import org.bukkit.Location;
|
+import org.bukkit.Location;
|
||||||
@ -227,6 +227,14 @@ index 0000000000000000000000000000000000000000..43f062257472a06e9e64c2feef6c3b10
|
|||||||
+ * @return The closest point the path can get to the target location
|
+ * @return The closest point the path can get to the target location
|
||||||
+ */
|
+ */
|
||||||
+ @Nullable Location getFinalPoint();
|
+ @Nullable Location getFinalPoint();
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Checks whether the final point can be reached
|
||||||
|
+ *
|
||||||
|
+ * @return whether the final point can be reached
|
||||||
|
+ * @see #getFinalPoint()
|
||||||
|
+ */
|
||||||
|
+ boolean canReachFinalPoint();
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
diff --git a/src/main/java/org/bukkit/entity/Mob.java b/src/main/java/org/bukkit/entity/Mob.java
|
||||||
|
@ -12,10 +12,10 @@ public net.minecraft.world.level.pathfinder.Path nodes
|
|||||||
|
|
||||||
diff --git a/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
diff --git a/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000000000000000000000000000000000000..064712e7b27a200b29c72076a82f4f5611fa507f
|
index 0000000000000000000000000000000000000000..3dbe4cf29a7984a1976a60bdeeb3ede02316a3cb
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
+++ b/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java
|
||||||
@@ -0,0 +1,143 @@
|
@@ -0,0 +1,148 @@
|
||||||
+package com.destroystokyo.paper.entity;
|
+package com.destroystokyo.paper.entity;
|
||||||
+
|
+
|
||||||
+import org.apache.commons.lang.Validate;
|
+import org.apache.commons.lang.Validate;
|
||||||
@ -132,6 +132,11 @@ index 0000000000000000000000000000000000000000..064712e7b27a200b29c72076a82f4f56
|
|||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
|
+ public boolean canReachFinalPoint() {
|
||||||
|
+ return path.canReach();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
+ public List<Location> getPoints() {
|
+ public List<Location> getPoints() {
|
||||||
+ List<Location> points = new ArrayList<>();
|
+ List<Location> points = new ArrayList<>();
|
||||||
+ for (Node point : path.nodes) {
|
+ for (Node point : path.nodes) {
|
||||||
|
Loading…
Reference in New Issue
Block a user