From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Sat, 14 Aug 2021 14:49:45 +0100 Subject: [PATCH] ChunkMap.mainInvokingExecutor This is a temp patch, this should maybe be moved to a more generic map or potentially wrapped into mcutil for the sake of this being such a generic concept anyways diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; private final BlockableEventLoop mainThreadExecutor; + final java.util.concurrent.Executor mainInvokingExecutor; // Paper // Paper - Move to MCUtil? public final ChunkGenerator generator; public final Supplier overworldDataStorage; private final PoiManager poiManager; @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.level = world; this.generator = chunkGenerator; this.mainThreadExecutor = mainThreadExecutor; + // Paper start + this.mainInvokingExecutor = (run) -> { + if (MCUtil.isMainThread()) { + run.run(); + } else { + mainThreadExecutor.execute(run); + } + }; + // Paper end ProcessorMailbox threadedmailbox = ProcessorMailbox.create(executor, "worldgen"); Objects.requireNonNull(mainThreadExecutor);