Paper/Spigot-Server-Patches/0078-EntityPathfindEvent.patch
Spottedleaf 5c7081fecc Update upstream & fix some chunk related issues (#2177)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories

CraftBukkit Changes:
4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories
e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.
d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs

* Bring Chunk load checks in-line with spigot

As of the last upstream merge spigot now checks ticket level status
when returning loaded chunks for a world from api. Now our checks
will respect that decision.

* Fix spawn ticket levels

Vanilla would keep the inner chunks of spawn available for ticking,
however my changes made all chunks non-ticking. Resolve by changing
ticket levels for spawn chunks inside the border to respect this
behavior.


* Make World#getChunkIfLoadedImmediately return only entity ticking chunks

Mojang appears to be using chunks with level > 33 (non-ticking chunks)
as cached chunks and not actually loaded chunks.

* Bring all loaded checks in line with spigot

Loaded chunks must be at least border  chunks, or level <= 33
2019-06-14 03:27:40 +01:00

97 Zeilen
4.3 KiB
Diff

From 9cc229d9a2b2e314802d77dd02a9183da09afff3 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.
diff --git a/src/main/java/net/minecraft/server/Navigation.java b/src/main/java/net/minecraft/server/Navigation.java
index aacaecd82d..bc30e3f339 100644
--- 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() {
diff --git a/src/main/java/net/minecraft/server/NavigationAbstract.java b/src/main/java/net/minecraft/server/NavigationAbstract.java
index 75e01c2420..d04eb1bbfe 100644
--- 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;
@@ -71,13 +71,15 @@ public abstract class NavigationAbstract {
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, Entity target) {
+ // 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
@@ -87,11 +89,12 @@ public abstract class NavigationAbstract {
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
}
@Nullable
- protected PathEntity a(BlockPosition blockposition, double d0, double d1, double d2, int i, boolean flag) {
+ 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) {
if (this.a.locY < 0.0D) {
return null;
} else if (!this.a()) {
@@ -99,6 +102,12 @@ public abstract class NavigationAbstract {
} 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(),
+ MCUtil.toLocation(getEntity().world, blockposition), target == null ? null : target.getBukkitEntity()).callEvent()) {
+ return null;
+ }
+ // Paper end
this.q = blockposition.immutableCopy();
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 9dfca6067f..551ff417bd 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