From 9ae65d1b3e4f23e46fb65546276ff091ffeac951 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Tue, 8 Aug 2023 18:16:25 -0700 Subject: [PATCH] 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 --- patches/server/0003-Threaded-Regions.patch | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/patches/server/0003-Threaded-Regions.patch b/patches/server/0003-Threaded-Regions.patch index 9830319..b52e1db 100644 --- a/patches/server/0003-Threaded-Regions.patch +++ b/patches/server/0003-Threaded-Regions.patch @@ -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; + }