diff --git a/patches/server/0024-Make-loadChunksAsync-callback-thread-safe.patch b/patches/server/0024-Make-loadChunksAsync-callback-thread-safe.patch new file mode 100644 index 0000000..1ef9360 --- /dev/null +++ b/patches/server/0024-Make-loadChunksAsync-callback-thread-safe.patch @@ -0,0 +1,21 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +Date: Tue, 25 Jul 2023 11:47:18 -0700 +Subject: [PATCH] Make loadChunksAsync callback thread-safe + +Need to perform synchronisation on the return list to avoid CMEs + +diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java +index 60b409e873d8f5d7975cce6e86ee2ed5525d348c..cf8f93734121e5c1959959f0ba13ee4e6db31959 100644 +--- a/src/main/java/net/minecraft/server/level/ServerLevel.java ++++ b/src/main/java/net/minecraft/server/level/ServerLevel.java +@@ -347,7 +347,9 @@ public class ServerLevel extends Level implements WorldGenLevel { + + java.util.function.Consumer consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> { + if (chunk != null) { ++ synchronized (ret) { // Folia - region threading - make callback thread-safe TODO rebase + ret.add(chunk); ++ } // Folia - region threading - make callback thread-safe TODO rebase + chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier); + } + if (loadedChunks.incrementAndGet() == requiredChunks) {