From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Thu, 8 Apr 2021 06:22:15 -0700
Subject: [PATCH] Do not update TE's in generating chunks

It might cause a deadlock with the getType call to the
chunk.

diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
index 9b82ff37faaafc3a799413f6949fb88a993aa9a0..13983f3271d33ab6e4c7030de5865edbd7b0cd8a 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/DefinedStructure.java
@@ -374,7 +374,13 @@ public class DefinedStructure {
                         if (pair1.getSecond() != null) {
                             tileentity = worldaccess.getTileEntity(blockposition3);
                             if (tileentity != null) {
+                                // Tuinity start - do not update TE's in generating chunks, it might cause a deadlock
+                                if (!(worldaccess instanceof World)) {
+                                    tileentity.invalidateBlockCache();
+                                } else {
+                                // Tuinity end - do not update TE's in generating chunks, it might cause a deadlock
                                 tileentity.update();
+                                } // Tuinity - do not update TE's in generating chunks, it might cause a deadlock
                             }
                         }
                     }
