From 92803c14313b5cfc5233b87681224509507ef209 Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 27 May 2016 21:41:26 -0400 Subject: [PATCH] Ensure Chunks never ever load async Safely pushes the operation to main thread, then back to the posting thread diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java index 7b7a3d0..9aaca21 100644 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java +++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOExecutor.java @@ -4,6 +4,7 @@ import com.destroystokyo.paper.PaperConfig; import net.minecraft.server.Chunk; import net.minecraft.server.ChunkProviderServer; import net.minecraft.server.ChunkRegionLoader; +import net.minecraft.server.MCUtil; // Paper import net.minecraft.server.World; import org.bukkit.craftbukkit.util.AsynchronousExecutor; @@ -14,7 +15,7 @@ public class ChunkIOExecutor { private static final AsynchronousExecutor instance = new AsynchronousExecutor(new ChunkIOProvider(), BASE_THREADS); public static Chunk syncChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z) { - return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider)); + return MCUtil.ensureMain("Async Chunk Load", () -> instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider))); // Paper } public static void queueChunkLoad(World world, ChunkRegionLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) { diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java index 3a95b44..229fa6c 100644 --- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java +++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java @@ -33,8 +33,8 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider