mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-21 07:49:18 +00:00
some fixes
This commit is contained in:
@@ -159,6 +159,7 @@ public class DivineConfig {
|
||||
public static int parallelThreadCount = 4;
|
||||
public static boolean logContainerCreationStacktraces = false;
|
||||
public static boolean disableHardThrow = false;
|
||||
public static boolean pwtCompatabilityMode = false;
|
||||
private static void parallelWorldTicking() {
|
||||
enableParallelWorldTicking = getBoolean("settings.parallel-world-ticking.enable", enableParallelWorldTicking,
|
||||
"Enables Parallel World Ticking, which executes each world’s tick in a separate thread while ensuring that all worlds complete their tick before the next cycle begins.",
|
||||
@@ -168,6 +169,8 @@ public class DivineConfig {
|
||||
logContainerCreationStacktraces = getBoolean("settings.parallel-world-ticking.log-container-creation-stacktraces", logContainerCreationStacktraces);
|
||||
disableHardThrow = getBoolean("settings.parallel-world-ticking.disable-hard-throw", disableHardThrow,
|
||||
"Disables annoying 'not on main thread' throws. But, THIS IS NOT RECOMMENDED because you SHOULD FIX THE ISSUES THEMSELVES instead of RISKING DATA CORRUPTION! If you lose something, take the blame on yourself.");
|
||||
pwtCompatabilityMode = getBoolean("settings.parallel-world-ticking.compatability-mode", pwtCompatabilityMode,
|
||||
"Enables compatibility mode for plugins that are not compatible with Parallel World Ticking. This makes all async tasks run synchronously.");
|
||||
}
|
||||
|
||||
public static boolean nativeAccelerationEnabled = true;
|
||||
@@ -181,6 +184,7 @@ public class DivineConfig {
|
||||
public static ChunkTaskPriority chunkTaskPriority = ChunkTaskPriority.EUCLIDEAN_CIRCLE_PATTERN;
|
||||
public static int threadPoolPriority = Thread.NORM_PRIORITY + 1;
|
||||
public static boolean enableAsyncNoiseFill = false;
|
||||
public static boolean asyncChunkSendingEnabled = true;
|
||||
public static boolean enableSecureSeed = false;
|
||||
public static boolean smoothBedrockLayer = false;
|
||||
public static boolean slopesVisualFix = false;
|
||||
@@ -238,6 +242,8 @@ public class DivineConfig {
|
||||
"",
|
||||
"Terrain and biome generation remains the same, but all the ores and structures are generated with 1024-bit seed, instead of the usual 64-bit seed.",
|
||||
"This seed is almost impossible to crack, and there are no weird links between structures.");
|
||||
asyncChunkSendingEnabled = getBoolean("settings.chunk-generation.enable-async-chunk-sending", asyncChunkSendingEnabled,
|
||||
"Makes chunk sending asynchronous, which can significantly reduce main thread load when many players are loading chunks.");
|
||||
|
||||
smoothBedrockLayer = getBoolean("settings.chunk-generation.smooth-bedrock-layer", smoothBedrockLayer,
|
||||
"Smoothens the bedrock layer at the bottom of overworld, and on the top of nether during the world generation.");
|
||||
@@ -256,20 +262,6 @@ public class DivineConfig {
|
||||
"modpacks where many structure mods are using very high weight values in their template pools.");
|
||||
}
|
||||
|
||||
public static boolean asyncChunkSendingEnabled = true;
|
||||
public static int asyncChunkSendingThreadCount = 1;
|
||||
public static boolean asyncChunkSendingUseVirtualThreads = false;
|
||||
private static void asyncChunkSending() {
|
||||
asyncChunkSendingEnabled = getBoolean("settings.async-chunk-sending.enable", asyncChunkSendingEnabled,
|
||||
"Enables chunk sending runs off-main thread.");
|
||||
|
||||
asyncChunkSendingThreadCount = getInt("settings.async-chunk-sending.thread-count", asyncChunkSendingThreadCount,
|
||||
"Amount of threads to use for async chunk sending. (If use-virtual-threads is enabled, this will be ignored)");
|
||||
|
||||
asyncChunkSendingUseVirtualThreads = getBoolean("settings.async-chunk-sending.use-virtual-threads", asyncChunkSendingUseVirtualThreads,
|
||||
"Similar to the 'virtual-thread' options. This will use the virtual thread executor for chunk sending.");
|
||||
}
|
||||
|
||||
public static boolean enableRegionizedChunkTicking = false;
|
||||
public static int regionizedChunkTickingExecutorThreadCount = 4;
|
||||
public static int regionizedChunkTickingExecutorThreadPriority = Thread.NORM_PRIORITY + 2;
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
package org.bxteam.divinemc.server.chunk;
|
||||
|
||||
import ca.spottedleaf.moonrise.common.util.TickThread;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import org.bxteam.divinemc.DivineConfig;
|
||||
import org.bxteam.divinemc.util.NamedAgnosticThreadFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public class ChunkSendingExecutor {
|
||||
private static final ExecutorService SERVICE = DivineConfig.asyncChunkSendingEnabled
|
||||
? DivineConfig.asyncChunkSendingUseVirtualThreads ?
|
||||
Executors.newVirtualThreadPerTaskExecutor() :
|
||||
Executors.newFixedThreadPool(
|
||||
DivineConfig.asyncChunkSendingThreadCount,
|
||||
new NamedAgnosticThreadFactory<>("chunk_sending", TickThread::new, Thread.NORM_PRIORITY)
|
||||
)
|
||||
: null;
|
||||
|
||||
public static void execute(Runnable runnable, ServerLevel level) {
|
||||
runnable = wrapRunnable(runnable, level);
|
||||
if (DivineConfig.asyncChunkSendingEnabled) {
|
||||
SERVICE.submit(runnable);
|
||||
} else {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
private static @NotNull Runnable wrapRunnable(Runnable runnable, final ServerLevel level) {
|
||||
return () -> {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Throwable throwable) {
|
||||
MinecraftServer.LOGGER.warn("Failed to send chunk data! Retrying...");
|
||||
level.getServer().scheduleOnMain(() -> {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Throwable failed) {
|
||||
MinecraftServer.LOGGER.error("Failed to send chunk data! (2nd attempt). Logging error log", failed);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user