13
0
geforkt von Mirrors/Paper

Expand Pathfinding API with more options

Dieser Commit ist enthalten in:
MiniDigger | Martin 2020-05-16 15:15:11 +02:00
Ursprung 8743a66ca2
Commit 792993faca
2 geänderte Dateien mit 89 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -157,6 +157,48 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ boolean moveTo(@NotNull PathResult path, double speed);
+
+ /**
+ * Checks if this pathfinder allows passing through closed doors.
+ *
+ * @return if this pathfinder allows passing through closed doors
+ */
+ boolean canOpenDoors();
+
+ /**
+ * Allows this pathfinder to pass through closed doors, or not
+ *
+ * @param canOpenDoors if the mob can pass through closed doors, or not
+ */
+ void setCanOpenDoors(boolean canOpenDoors);
+
+ /**
+ * Checks if this pathfinder allows passing through open doors.
+ *
+ * @return if this pathfinder allows passing through open doors
+ */
+ boolean canPassDoors();
+
+ /**
+ * Allows this pathfinder to pass through open doors, or not
+ *
+ * @param canPassDoors if the mob can pass through open doors, or not
+ */
+ void setCanPassDoors(boolean canPassDoors);
+
+ /**
+ * Checks if this pathfinder assumes that the mob can float
+ *
+ * @return if this pathfinder assumes that the mob can float
+ */
+ boolean canFloat();
+
+ /**
+ * Makes this pathfinder assume that the mob can float, or not
+ *
+ * @param canFloat if the mob can float, or not
+ */
+ void setCanFloat(boolean canFloat);
+
+ /**
+ * Represents the result of a pathfinding calculation
+ */
+ interface PathResult {

Datei anzeigen

@ -80,6 +80,36 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return entity.getNavigation().setDestination(pathEntity, speed);
+ }
+
+ @Override
+ public boolean canOpenDoors() {
+ return entity.getNavigation().getPathfinder().getPathfinder().shouldOpenDoors();
+ }
+
+ @Override
+ public void setCanOpenDoors(boolean canOpenDoors) {
+ entity.getNavigation().getPathfinder().getPathfinder().setShouldOpenDoors(canOpenDoors);
+ }
+
+ @Override
+ public boolean canPassDoors() {
+ return entity.getNavigation().getPathfinder().getPathfinder().shouldPassDoors();
+ }
+
+ @Override
+ public void setCanPassDoors(boolean canPassDoors) {
+ entity.getNavigation().getPathfinder().getPathfinder().setShouldPassDoors(canPassDoors);
+ }
+
+ @Override
+ public boolean canFloat() {
+ return entity.getNavigation().getPathfinder().getPathfinder().shouldFloat();
+ }
+
+ @Override
+ public void setCanFloat(boolean canFloat) {
+ entity.getNavigation().getPathfinder().getPathfinder().setShouldFloat(canFloat);
+ }
+
+ public class PaperPathResult implements com.destroystokyo.paper.entity.PaperPathfinder.PathResult {
+
+ private final PathEntity path;
@ -226,6 +256,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private final int m;
public int d = -1;
public float e;
diff --git a/src/main/java/net/minecraft/server/PathfinderAbstract.java b/src/main/java/net/minecraft/server/PathfinderAbstract.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/PathfinderAbstract.java
+++ b/src/main/java/net/minecraft/server/PathfinderAbstract.java
@@ -0,0 +0,0 @@ public abstract class PathfinderAbstract {
protected int d;
protected int e;
protected int f;
- protected boolean g;
- protected boolean h;
- protected boolean i;
+ protected boolean g; public boolean shouldPassDoors() { return g; } public void setShouldPassDoors(boolean b) { g = b; } // Paper - obfhelper
+ protected boolean h; public boolean shouldOpenDoors() { return h; } public void setShouldOpenDoors(boolean b) { h = b; } // Paper - obfhelper
+ protected boolean i; public boolean shouldFloat() { return i; } public void setShouldFloat(boolean b) { i = b; } // Paper - obfhelper
public PathfinderAbstract() {}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java