Additionally remove Mob target if the target is removed

If the target is removed, then it is possible that
using the CraftEntity could retrieve a teleported
entity. This would cause the Mob to be removed
when getHandle() is invoked.

Fixes https://github.com/PaperMC/Folia/issues/117
This commit is contained in:
Spottedleaf 2023-08-08 18:16:25 -07:00
parent bd72070fb9
commit 9ae65d1b3e

View File

@ -17872,7 +17872,7 @@ index e11d7283662834047b2ff81a2fd25a4263792deb..40dd667bacd296a3a329391dc87a5713
while (!flag2 && blockposition.getY() > world.getMinBuildHeight()) {
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..a8b23b1594d2b39568c68c93a8a1b936457672bc 100644
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..a21edc7df32a59a6cb1af3865d2ce35f72cf8afc 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -134,6 +134,14 @@ public abstract class Mob extends LivingEntity implements Targeting {
@ -17895,7 +17895,7 @@ index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..a8b23b1594d2b39568c68c93a8a1b936
@Override
public LivingEntity getTarget() {
+ // Folia start - region threading
+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target)) {
+ if (this.target != null && (!io.papermc.paper.util.TickThread.isTickThreadFor(this.target) || this.target.isRemoved())) {
+ this.target = null;
+ return null;
+ }