Skip to content

Commit

Permalink
Additionally remove Mob target if the target is removed
Browse files Browse the repository at this point in the history
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 #117
  • Loading branch information
Spottedleaf committed Aug 9, 2023
1 parent bd72070 commit 9ae65d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions patches/server/0003-Threaded-Regions.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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;
+ }
Expand Down

0 comments on commit 9ae65d1

Please sign in to comment.