2018-07-19 06:42:43 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
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.
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/Navigation.java b/src/main/java/net/minecraft/world/entity/ai/navigation/Navigation.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/Navigation.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/Navigation.java
|
2019-05-13 03:39:06 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class Navigation extends NavigationAbstract {
|
|
|
|
|
|
|
|
@Override
|
2019-07-20 06:01:24 +02:00
|
|
|
public PathEntity a(Entity entity, int i) {
|
2020-06-25 13:00:35 +02:00
|
|
|
- return this.a(entity.getChunkCoordinates(), i);
|
|
|
|
+ return this.a(entity.getChunkCoordinates(), entity, i); // Paper - Forward target entity
|
2019-05-13 03:39:06 +02:00
|
|
|
}
|
|
|
|
|
2020-09-11 01:47:58 +02:00
|
|
|
private int u() {
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationAbstract.java
|
2021-03-16 16:50:45 +01:00
|
|
|
@@ -0,0 +0,0 @@ import net.minecraft.core.BaseBlockPosition;
|
|
|
|
import net.minecraft.core.BlockPosition;
|
|
|
|
import net.minecraft.core.IPosition;
|
|
|
|
import net.minecraft.network.protocol.game.PacketDebug;
|
|
|
|
+import net.minecraft.server.MCUtil;
|
|
|
|
import net.minecraft.util.MathHelper;
|
|
|
|
import net.minecraft.world.entity.Entity;
|
|
|
|
import net.minecraft.world.entity.EntityInsentient;
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -0,0 +0,0 @@ import net.minecraft.world.phys.Vec3D;
|
2018-07-19 06:42:43 +02:00
|
|
|
|
|
|
|
public abstract class NavigationAbstract {
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
- protected final EntityInsentient a;
|
|
|
|
+ protected final EntityInsentient a; public Entity getEntity() { return a; } // Paper - OBFHELPER
|
|
|
|
protected final World b;
|
2018-07-19 06:42:43 +02:00
|
|
|
@Nullable
|
|
|
|
protected PathEntity c;
|
|
|
|
@@ -0,0 +0,0 @@ public abstract class NavigationAbstract {
|
2019-04-27 05:05:36 +02:00
|
|
|
|
2019-07-20 06:01:24 +02:00
|
|
|
@Nullable
|
|
|
|
public PathEntity a(BlockPosition blockposition, int i) {
|
|
|
|
- return this.a(ImmutableSet.of(blockposition), 8, false, i);
|
|
|
|
+ // Paper start - add target parameter
|
|
|
|
+ return this.a(blockposition, null, i);
|
|
|
|
+ }
|
|
|
|
+ @Nullable public PathEntity a(BlockPosition blockposition, Entity target, int i) {
|
|
|
|
+ return this.a(ImmutableSet.of(blockposition), target, 8, false, i);
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nullable
|
2019-07-20 06:01:24 +02:00
|
|
|
public PathEntity a(Entity entity, int i) {
|
2020-06-25 13:00:35 +02:00
|
|
|
- return this.a(ImmutableSet.of(entity.getChunkCoordinates()), 16, true, i);
|
|
|
|
+ return this.a(ImmutableSet.of(entity.getChunkCoordinates()), entity, 16, true, i); // Paper
|
2019-04-27 05:05:36 +02:00
|
|
|
}
|
|
|
|
|
2019-05-14 04:20:58 +02:00
|
|
|
@Nullable
|
2019-07-20 06:01:24 +02:00
|
|
|
+ // Paper start - Add target
|
|
|
|
protected PathEntity a(Set<BlockPosition> set, int i, boolean flag, int j) {
|
|
|
|
+ return this.a(set, null, i, flag, j);
|
|
|
|
+ }
|
|
|
|
+ @Nullable protected PathEntity a(Set<BlockPosition> set, Entity target, int i, boolean flag, int j) {
|
|
|
|
+ // Paper end
|
|
|
|
if (set.isEmpty()) {
|
2019-04-27 05:05:36 +02:00
|
|
|
return null;
|
2019-12-11 03:43:21 +01:00
|
|
|
} else if (this.a.locY() < 0.0D) {
|
2019-05-14 04:20:58 +02:00
|
|
|
@@ -0,0 +0,0 @@ public abstract class NavigationAbstract {
|
2020-08-25 04:22:08 +02:00
|
|
|
} else if (this.c != null && !this.c.c() && set.contains(this.p)) {
|
2018-07-19 06:42:43 +02:00
|
|
|
return this.c;
|
|
|
|
} else {
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper start - Pathfind event
|
2019-07-20 06:01:24 +02:00
|
|
|
+ boolean copiedSet = false;
|
|
|
|
+ for (BlockPosition possibleTarget : set) {
|
|
|
|
+ if (!new com.destroystokyo.paper.event.entity.EntityPathfindEvent(getEntity().getBukkitEntity(),
|
|
|
|
+ MCUtil.toLocation(getEntity().world, possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) {
|
|
|
|
+ if (!copiedSet) {
|
|
|
|
+ copiedSet = true;
|
|
|
|
+ set = new java.util.HashSet<>(set);
|
|
|
|
+ }
|
|
|
|
+ // note: since we copy the set this remove call is safe, since we're iterating over the old copy
|
|
|
|
+ set.remove(possibleTarget);
|
|
|
|
+ if (set.isEmpty()) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
2019-04-27 05:05:36 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
2019-07-20 06:01:24 +02:00
|
|
|
this.b.getMethodProfiler().enter("pathfind");
|
2020-06-25 13:00:35 +02:00
|
|
|
float f = (float) this.a.b(GenericAttributes.FOLLOW_RANGE);
|
|
|
|
BlockPosition blockposition = flag ? this.a.getChunkCoordinates().up() : this.a.getChunkCoordinates();
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationFlying.java b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationFlying.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationFlying.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/ai/navigation/NavigationFlying.java
|
2019-04-27 05:05:36 +02:00
|
|
|
@@ -0,0 +0,0 @@ public class NavigationFlying extends NavigationAbstract {
|
|
|
|
|
|
|
|
@Override
|
2019-07-20 06:01:24 +02:00
|
|
|
public PathEntity a(Entity entity, int i) {
|
2020-06-25 13:00:35 +02:00
|
|
|
- return this.a(entity.getChunkCoordinates(), i);
|
|
|
|
+ return this.a(entity.getChunkCoordinates(), entity, i); // Paper - Forward target entity
|
2019-04-27 05:05:36 +02:00
|
|
|
}
|
2019-01-01 04:15:55 +01:00
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
@Override
|