Folia/patches/server/0012-Block-reading-in-world-tile-entities-on-worldgen-thr.patch
Spottedleaf 4a59238743 Update to 1.20.2
Very early build, network configuration switching is supported
but not tested (note: changes need to be backported to Paper)

Changes:
 - Supports per player mob caps
 - Adds entity tracker optimisations which are not in Paper
   (and will not be ported to Paper due to plugin conflicts)
 - No longer reverts paper distance map optimisations, as
   those are replaced by the NearbyPlayers class

These changes should bring Folia in-line with Paper's optimisations
at least (probably more given the entity tracker optimisations),
still missing features like world loading / some commands
2023-09-26 13:28:33 -07:00

25 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Sun, 23 Apr 2023 07:08:26 -0700
Subject: [PATCH] Block reading in-world tile entities on worldgen threads
The returned TE may be in the world, in which case it is unsafe
for the current thread to modify or access its contents.
diff --git a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
index 4a3ac7dedf5cb1e76f16ec4f18e82afc717d0ced..44609fb7965a03283e2bb50e483a8f60254de510 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ImposterProtoChunk.java
@@ -84,6 +84,11 @@ public class ImposterProtoChunk extends ProtoChunk {
@Nullable
@Override
public BlockEntity getBlockEntity(BlockPos pos) {
+ // Folia start - block reading possibly in-world block data for worldgen threads
+ if (!this.allowWrites && !io.papermc.paper.util.TickThread.isTickThread()) {
+ return null;
+ }
+ // Folia end - block reading possibly in-world block data for worldgen threads
return this.wrapped.getBlockEntity(pos);
}