mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
41 lines
2.4 KiB
Diff
41 lines
2.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
|
Date: Tue, 28 Jan 2025 01:14:58 +0300
|
|
Subject: [PATCH] Threaded light engine
|
|
|
|
|
|
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
|
index d3d9926d504fa6b3384be5ae06b2843ebb7f807c..72f019e3034d3268cf5526237ff0927eccc0c5bb 100644
|
|
--- a/net/minecraft/server/level/ChunkMap.java
|
|
+++ b/net/minecraft/server/level/ChunkMap.java
|
|
@@ -210,7 +210,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen");
|
|
this.progressListener = progressListener;
|
|
this.chunkStatusListener = chunkStatusListener;
|
|
- ConsecutiveExecutor consecutiveExecutor1 = new ConsecutiveExecutor(dispatcher, "light");
|
|
+ ConsecutiveExecutor consecutiveExecutor1 = onLightExecutorInit(ConsecutiveExecutor::new); // DivineMC - Threaded light engine
|
|
// Paper - rewrite chunk system
|
|
this.lightEngine = new ThreadedLevelLightEngine(
|
|
lightChunk, this, this.level.dimensionType().hasSkyLight(), consecutiveExecutor1, null // Paper - rewrite chunk system
|
|
@@ -230,6 +230,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
|
this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system
|
|
}
|
|
|
|
+ // DivineMC start - Threaded light engine
|
|
+ private java.util.concurrent.ExecutorService lightThread = null;
|
|
+
|
|
+ private ConsecutiveExecutor onLightExecutorInit(java.util.function.BiFunction<java.util.concurrent.Executor, String, net.minecraft.util.thread.ConsecutiveExecutor> original) {
|
|
+ lightThread = new java.util.concurrent.ThreadPoolExecutor(
|
|
+ 1, 1,
|
|
+ 0, java.util.concurrent.TimeUnit.SECONDS,
|
|
+ new java.util.concurrent.LinkedBlockingQueue<>(),
|
|
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setPriority(Thread.NORM_PRIORITY - 1).setDaemon(true).setNameFormat(String.format("%s - Light", level.dimension().location().toDebugFileName())).build()
|
|
+ );
|
|
+ return original.apply(lightThread, "light");
|
|
+ }
|
|
+ // DivineMC end - Threaded light engine
|
|
+
|
|
private void setChunkUnsaved(ChunkPos chunkPos) {
|
|
// Paper - rewrite chunk system
|
|
}
|