From 792993facad35c1843c6f7acc04ffd6cd6dfd4e1 Mon Sep 17 00:00:00 2001
From: MiniDigger | Martin <admin@minidigger.dev>
Date: Sat, 16 May 2020 15:15:11 +0200
Subject: [PATCH] Expand Pathfinding API with more options

---
 Spigot-API-Patches/Mob-Pathfinding-API.patch  | 42 +++++++++++++++++
 .../Mob-Pathfinding-API.patch                 | 47 +++++++++++++++++++
 2 files changed, 89 insertions(+)

diff --git a/Spigot-API-Patches/Mob-Pathfinding-API.patch b/Spigot-API-Patches/Mob-Pathfinding-API.patch
index e80321b108..a8edb05ffd 100644
--- a/Spigot-API-Patches/Mob-Pathfinding-API.patch
+++ b/Spigot-API-Patches/Mob-Pathfinding-API.patch
@@ -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 {
diff --git a/Spigot-Server-Patches/Mob-Pathfinding-API.patch b/Spigot-Server-Patches/Mob-Pathfinding-API.patch
index e17bec1ca8..8d4e03eeff 100644
--- a/Spigot-Server-Patches/Mob-Pathfinding-API.patch
+++ b/Spigot-Server-Patches/Mob-Pathfinding-API.patch
@@ -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