--- a/net/minecraft/world/entity/ai/Brain.java
+++ b/net/minecraft/world/entity/ai/Brain.java
@@ -425,9 +_,17 @@
     }
 
     public void stopAll(ServerLevel level, E owner) {
+        // Folia start - region threading
+        List<BehaviorControl<? super E>> behaviors = this.getRunningBehaviors();
+        if (behaviors.isEmpty()) {
+            // avoid calling getGameTime, as this may be called while portalling an entity - which will cause
+            // the world data retrieval to fail
+            return;
+        }
+        // Folia end - region threading
         long gameTime = owner.level().getGameTime();
 
-        for (BehaviorControl<? super E> behaviorControl : this.getRunningBehaviors()) {
+        for (BehaviorControl<? super E> behaviorControl : behaviors) { // Folia - region threading
             behaviorControl.doStop(level, owner, gameTime);
         }
     }
