mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-21 07:49:18 +00:00
merge and update some patches
This commit is contained in:
@@ -185,7 +185,6 @@ public class DivineConfig {
|
||||
public static ChunkSystemAlgorithms chunkWorkerAlgorithm = ChunkSystemAlgorithms.C2ME;
|
||||
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;
|
||||
@@ -223,8 +222,6 @@ public class DivineConfig {
|
||||
" - DEFAULT_DIAMOND_PATTERN: Default one, chunk priorities will be ordered in a diamond pattern"));
|
||||
threadPoolPriority = getInt("settings.chunks.thread-pool-priority", threadPoolPriority,
|
||||
"Sets the priority of the thread pool used for chunk generation");
|
||||
enableAsyncNoiseFill = getBoolean("settings.chunks.enable-async-noise-fill", enableAsyncNoiseFill,
|
||||
"Runs noise filling and biome populating in a virtual thread executor. If disabled, it will run sync.");
|
||||
|
||||
enableSecureSeed = getBoolean("settings.chunks.enable-secure-seed", enableSecureSeed,
|
||||
"This feature is based on Secure Seed mod by Earthcomputer.",
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package org.bxteam.divinemc.util;
|
||||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.DynamicOps;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class SynchronizedCodec<A> implements Codec<A> {
|
||||
private final ReentrantLock lock = new ReentrantLock(false);
|
||||
private final Codec<A> delegate;
|
||||
|
||||
public SynchronizedCodec(Codec<A> delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> DataResult<Pair<A, T>> decode(DynamicOps<T> ops, T input) {
|
||||
try {
|
||||
lock.lockInterruptibly();
|
||||
return this.delegate.decode(ops, input);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> DataResult<T> encode(A input, DynamicOps<T> ops, T prefix) {
|
||||
try {
|
||||
lock.lockInterruptibly();
|
||||
return this.delegate.encode(input, ops, prefix);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
if (lock.isHeldByCurrentThread()) lock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user