2019-05-14 04:20:58 +02:00
|
|
|
From c7641c30bd926b4c5d123ed4f9943bfbaad76ee7 Mon Sep 17 00:00:00 2001
|
2019-04-27 05:05:36 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Mon, 28 Mar 2016 21:22:26 -0400
|
|
|
|
Subject: [PATCH] EntityPathfindEvent
|
|
|
|
|
|
|
|
Fires when an Entity decides to start moving to a location.
|
|
|
|
|
2019-05-13 03:39:06 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Navigation.java b/src/main/java/net/minecraft/server/Navigation.java
|
2019-05-14 04:20:58 +02:00
|
|
|
index aacaecd82..bc30e3f33 100644
|
2019-05-13 03:39:06 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Navigation.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Navigation.java
|
|
|
|
@@ -60,7 +60,7 @@ 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() {
|
2019-04-27 05:05:36 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
2019-05-14 04:20:58 +02:00
|
|
|
index 75e01c242..d04eb1bbf 100644
|
2019-04-27 05:05:36 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/NavigationAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NavigationAbstract.java
|
|
|
|
@@ -4,7 +4,7 @@ import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
public abstract class NavigationAbstract {
|
|
|
|
|
|
|
|
- protected final EntityInsentient a;
|
|
|
|
+ protected final EntityInsentient a; public Entity getEntity() { return a; } // Paper - OBFHELPER
|
|
|
|
protected final World b;
|
|
|
|
@Nullable
|
|
|
|
protected PathEntity c;
|
2019-05-13 03:39:06 +02:00
|
|
|
@@ -71,13 +71,15 @@ public abstract class NavigationAbstract {
|
2019-04-27 05:05:36 +02:00
|
|
|
return this.b(new BlockPosition(d0, d1, d2));
|
|
|
|
}
|
|
|
|
|
2019-05-13 03:39:06 +02:00
|
|
|
- @Nullable
|
|
|
|
- public PathEntity b(BlockPosition blockposition) {
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper start - Add target entity parameter for path find event
|
|
|
|
+ @Nullable public PathEntity b(BlockPosition blockposition) { return this.b(blockposition, null); }
|
2019-05-13 03:39:06 +02:00
|
|
|
+ @Nullable public PathEntity b(BlockPosition blockposition, Entity target) {
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper end
|
|
|
|
float f = (float) blockposition.getX() + 0.5F;
|
|
|
|
float f1 = (float) blockposition.getY() + 0.5F;
|
|
|
|
float f2 = (float) blockposition.getZ() + 0.5F;
|
|
|
|
|
|
|
|
- return this.a(blockposition, (double) f, (double) f1, (double) f2, 8, false);
|
|
|
|
+ return this.a(blockposition, target, (double) f, (double) f1, (double) f2, 8, false); // Paper - Path find event
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
2019-05-14 04:20:58 +02:00
|
|
|
@@ -87,11 +89,12 @@ public abstract class NavigationAbstract {
|
2019-04-27 05:05:36 +02:00
|
|
|
double d1 = entity.getBoundingBox().minY;
|
|
|
|
double d2 = entity.locZ;
|
|
|
|
|
|
|
|
- return this.a(blockposition, d0, d1, d2, 16, true);
|
|
|
|
+ return this.a(blockposition, entity, d0, d1, d2, 16, true); // Paper - Path find event
|
|
|
|
}
|
|
|
|
|
2019-05-14 04:20:58 +02:00
|
|
|
@Nullable
|
2019-05-13 03:39:06 +02:00
|
|
|
- protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) {
|
2019-05-14 04:20:58 +02:00
|
|
|
+ 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); }
|
2019-05-13 03:39:06 +02:00
|
|
|
+ @Nullable protected PathEntity a(BlockPosition blockposition, Entity target, double d0, double d1, double d2, int i, boolean flag) {
|
2019-05-14 04:20:58 +02:00
|
|
|
if (this.a.locY < 0.0D) {
|
2019-04-27 05:05:36 +02:00
|
|
|
return null;
|
2019-05-14 04:20:58 +02:00
|
|
|
} else if (!this.a()) {
|
|
|
|
@@ -99,6 +102,12 @@ public abstract class NavigationAbstract {
|
2019-04-27 05:05:36 +02:00
|
|
|
} else if (this.c != null && !this.c.b() && blockposition.equals(this.q)) {
|
|
|
|
return this.c;
|
|
|
|
} else {
|
|
|
|
+ // Paper start - Pathfind event
|
|
|
|
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(getEntity().getBukkitEntity(),
|
2019-05-14 04:20:58 +02:00
|
|
|
+ MCUtil.toLocation(getEntity().world, blockposition), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
2019-04-27 05:05:36 +02:00
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-05-14 04:20:58 +02:00
|
|
|
this.q = blockposition.immutableCopy();
|
2019-04-27 05:05:36 +02:00
|
|
|
float f = this.i();
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/NavigationFlying.java b/src/main/java/net/minecraft/server/NavigationFlying.java
|
|
|
|
index 9dfca6067..551ff417b 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/NavigationFlying.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NavigationFlying.java
|
|
|
|
@@ -25,7 +25,7 @@ public class NavigationFlying extends NavigationAbstract {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PathEntity a(Entity entity) {
|
|
|
|
- return this.b(new BlockPosition(entity));
|
|
|
|
+ return this.b(new BlockPosition(entity), entity); // Paper - Pathfind event
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
--
|
|
|
|
2.21.0
|
|
|
|
|