Review EntityPathfindEvent

Add missing target forward
This commit is contained in:
Spottedleaf 2019-05-12 18:39:06 -07:00
parent e36079cf6f
commit 6635ae643e
4 changed files with 25 additions and 12 deletions

View file

@ -18,7 +18,7 @@ index c76087614..475c93836 100644
}
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 6ce35018a..2a391be28 100644
index 7b27251b3..fe19167a1 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -0,0 +0,0 @@ public abstract class NavigationAbstract {

View file

@ -5,8 +5,21 @@ Subject: [PATCH] EntityPathfindEvent
Fires when an Entity decides to start moving to a location.
diff --git a/src/main/java/net/minecraft/server/Navigation.java b/src/main/java/net/minecraft/server/Navigation.java
index 79b2d9297..b6e3bf823 100644
--- a/src/main/java/net/minecraft/server/Navigation.java
+++ b/src/main/java/net/minecraft/server/Navigation.java
@@ -0,0 +0,0 @@ public class Navigation extends NavigationAbstract {
@Override
public PathEntity a(Entity entity) {
- return this.b(new BlockPosition(entity));
+ return this.b(new BlockPosition(entity), entity); // Paper - Forward target entity
}
private int s() {
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 2ced8dedd..6ce35018a 100644
index 2ced8dedd..7b27251b3 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -0,0 +0,0 @@ import javax.annotation.Nullable;
@ -22,11 +35,11 @@ index 2ced8dedd..6ce35018a 100644
return this.b(new BlockPosition(d0, d1, d2));
}
- @Nullable
- public PathEntity b(BlockPosition blockposition) {
+ // Paper start - Add target entity parameter for path find event
+ @Nullable public PathEntity b(BlockPosition blockposition) { return this.b(blockposition, null); }
@Nullable
- public PathEntity b(BlockPosition blockposition) {
+ public PathEntity b(BlockPosition blockposition, Entity target) {
+ @Nullable public PathEntity b(BlockPosition blockposition, Entity target) {
+ // Paper end
float f = (float) blockposition.getX() + 0.5F;
float f1 = (float) blockposition.getY() + 0.5F;
@ -45,11 +58,11 @@ index 2ced8dedd..6ce35018a 100644
+ return this.a(blockposition, entity, d0, d1, d2, 16, true); // Paper - Path find event
}
- @Nullable
- protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) {
+ // Paper start - Add target entity parameter for path find event
+ @Nullable protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) { return this.a(blockposition, null, d0, d1, d2, i, flag); }
@Nullable
- protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) {
+ protected PathEntity a(BlockPosition blockposition, Entity target, double d0, double d1, double d2, int i, boolean flag) {
+ @Nullable protected PathEntity a(BlockPosition blockposition, Entity target, double d0, double d1, double d2, int i, boolean flag) {
+ // Paper end
if (!this.a()) {
return null;

View file

@ -123,7 +123,7 @@ index 000000000..f68a07cb9
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 0586597e7..583f2c5ad 100644
index 6a1d5a899..f6a5aa27b 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -0,0 +0,0 @@ public abstract class NavigationAbstract {

View file

@ -6,12 +6,12 @@ Subject: [PATCH] Prevent Pathfinding out of World Border
This prevents Entities from trying to run outside of the World Border
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 2a391be28a..0586597e73 100644
index fe19167a1..6a1d5a899 100644
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
@@ -0,0 +0,0 @@ public abstract class NavigationAbstract {
@Nullable
protected PathEntity a(BlockPosition blockposition, Entity target, double d0, double d1, double d2, int i, boolean flag) {
@Nullable protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) { return this.a(blockposition, null, d0, d1, d2, i, flag); }
@Nullable protected PathEntity a(BlockPosition blockposition, Entity target, double d0, double d1, double d2, int i, boolean flag) {
// Paper end
+ if (!getEntity().getWorld().getWorldBorder().isInBounds(blockposition)) return null; // Paper - don't path out of world border
if (!this.a()) {