mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
update main build file and some patches
This commit is contained in:
@@ -3,7 +3,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
java
|
java
|
||||||
id("io.papermc.paperweight.patcher") version "2.0.0-beta.14"
|
id("io.papermc.paperweight.patcher") version "2.0.0-SNAPSHOT"
|
||||||
}
|
}
|
||||||
|
|
||||||
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/"
|
||||||
@@ -37,6 +37,27 @@ paperweight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
apply(plugin = "java")
|
||||||
|
apply(plugin = "maven-publish")
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(22)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.compileJava {
|
||||||
|
options.compilerArgs.add("-Xlint:-deprecation")
|
||||||
|
options.isWarnings = false
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile::class.java).configureEach {
|
||||||
|
options.isFork = true
|
||||||
|
options.forkOptions.memoryMaximumSize = "4G"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply(plugin = "java-library")
|
apply(plugin = "java-library")
|
||||||
apply(plugin = "maven-publish")
|
apply(plugin = "maven-publish")
|
||||||
@@ -65,10 +86,6 @@ subprojects {
|
|||||||
events(TestLogEvent.STANDARD_OUT)
|
events(TestLogEvent.STANDARD_OUT)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks.withType<AbstractArchiveTask>().configureEach {
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -4,6 +4,24 @@ Date: Mon, 24 Feb 2025 19:29:58 +0300
|
|||||||
Subject: [PATCH] Virtual Threads
|
Subject: [PATCH] Virtual Threads
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java
|
||||||
|
index 80a7a85e1a03a1ca406259207e1ae3b909b3284f..aa2d99de3d23d262542bfb1592fe084f94230f85 100644
|
||||||
|
--- a/net/minecraft/Util.java
|
||||||
|
+++ b/net/minecraft/Util.java
|
||||||
|
@@ -97,7 +97,12 @@ public class Util {
|
||||||
|
public static final TracingExecutor DIMENSION_DATA_IO_POOL = makeExtraIoExecutor("Dimension-Data-IO-Worker-"); // Paper - Separate dimension data IO pool
|
||||||
|
private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true);
|
||||||
|
// Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread
|
||||||
|
- public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() {
|
||||||
|
+ // DivineMC start - Virtual Threads
|
||||||
|
+ public static final ExecutorService PROFILE_EXECUTOR = org.bxteam.divinemc.DivineConfig.virtualThreadsEnabled && org.bxteam.divinemc.DivineConfig.virtualProfileLookupPool
|
||||||
|
+ ? Executors.newVirtualThreadPerTaskExecutor()
|
||||||
|
+ : Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory()
|
||||||
|
+ {
|
||||||
|
+ // DivineMC end - Virtual Threads
|
||||||
|
|
||||||
|
private final AtomicInteger count = new AtomicInteger();
|
||||||
|
|
||||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||||
index d7922847bd398d809e8b8a31bf136c804305a32b..559fd3d12dc5bc84bd976e684153295d8fb7cf64 100644
|
index d7922847bd398d809e8b8a31bf136c804305a32b..559fd3d12dc5bc84bd976e684153295d8fb7cf64 100644
|
||||||
--- a/net/minecraft/commands/Commands.java
|
--- a/net/minecraft/commands/Commands.java
|
||||||
@@ -36,7 +54,7 @@ index 85f81c83aff81133289a03f12a059729b7d2e00e..3f286034d50b53fbd71b4f64d83dc78b
|
|||||||
|
|
||||||
public ChatDecorator getChatDecorator() {
|
public ChatDecorator getChatDecorator() {
|
||||||
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
index 9e4ea539afcd07294bdc5018f479e496ee011451..afda1b0a1fd3ca278c75a822471a964ccbd09fc4 100644
|
index 4b5e31ba7b36be0e9dc75f0337c2282fa190fc85..d4e15d9295236fef5cbac3569cd37c1bd3c96d96 100644
|
||||||
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||||
@@ -800,8 +800,11 @@ public class ServerGamePacketListenerImpl
|
@@ -800,8 +800,11 @@ public class ServerGamePacketListenerImpl
|
||||||
@@ -70,3 +88,20 @@ index 45ea5fa0ef57724acce46008c53f7fa216cf78ee..f4a9d49247d2124b03273c38b14ddf96
|
|||||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||||
private final byte[] challenge;
|
private final byte[] challenge;
|
||||||
final MinecraftServer server;
|
final MinecraftServer server;
|
||||||
|
diff --git a/net/minecraft/server/network/ServerTextFilter.java b/net/minecraft/server/network/ServerTextFilter.java
|
||||||
|
index 5d18f6c3173ed257bef15637a53adbff26ee9062..c843e073db2a0046bbd5b64e1a4f4e956ce88a70 100644
|
||||||
|
--- a/net/minecraft/server/network/ServerTextFilter.java
|
||||||
|
+++ b/net/minecraft/server/network/ServerTextFilter.java
|
||||||
|
@@ -48,7 +48,11 @@ public abstract class ServerTextFilter implements AutoCloseable {
|
||||||
|
final ExecutorService workerPool;
|
||||||
|
|
||||||
|
protected static ExecutorService createWorkerPool(int size) {
|
||||||
|
- return Executors.newFixedThreadPool(size, THREAD_FACTORY);
|
||||||
|
+ // DivineMC start - Virtual Threads
|
||||||
|
+ return org.bxteam.divinemc.DivineConfig.virtualThreadsEnabled && org.bxteam.divinemc.DivineConfig.virtualServerTextFilterPool
|
||||||
|
+ ? Executors.newVirtualThreadPerTaskExecutor()
|
||||||
|
+ : Executors.newFixedThreadPool(size, THREAD_FACTORY);
|
||||||
|
+ // DivineMC end - Virtual Threads
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ServerTextFilter(
|
||||||
|
|||||||
@@ -5,18 +5,21 @@ Subject: [PATCH] Regionized Chunk Ticking
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||||
index 2678bf59d557f085c7265e2f3eb038647723d35e..ee4e5462c784ea8588c12eb2b248c708c4d84bee 100644
|
index 2678bf59d557f085c7265e2f3eb038647723d35e..f13ddc9a11ad0bc6396e31d7629f8ab9425cd4d7 100644
|
||||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||||
@@ -56,6 +56,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
@@ -56,6 +56,10 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
private static final Logger LOGGER = LogUtils.getLogger();
|
||||||
private final DistanceManager distanceManager;
|
private final DistanceManager distanceManager;
|
||||||
private final ServerLevel level;
|
private final ServerLevel level;
|
||||||
+ public static final Executor REGION_EXECUTOR = java.util.concurrent.Executors.newFixedThreadPool(org.bxteam.divinemc.DivineConfig.regionizedChunkTickingExecutorThreadCount, new org.bxteam.divinemc.util.NamedAgnosticThreadFactory<>("region_ticking", ca.spottedleaf.moonrise.common.util.TickThread::new, org.bxteam.divinemc.DivineConfig.regionizedChunkTickingExecutorThreadPriority)); // DivineMC - Regionized Chunk Ticking
|
+ // DivineMC - Regionized Chunk Ticking
|
||||||
|
+ public static final Executor REGION_EXECUTOR = java.util.concurrent.Executors.newFixedThreadPool(org.bxteam.divinemc.DivineConfig.regionizedChunkTickingExecutorThreadCount, new org.bxteam.divinemc.util.NamedAgnosticThreadFactory<>("region_ticking", ca.spottedleaf.moonrise.common.util.TickThread::new, org.bxteam.divinemc.DivineConfig.regionizedChunkTickingExecutorThreadPriority));
|
||||||
|
+ public volatile int tickingRegionsCount = 0;
|
||||||
|
+ // DivineMC end - Regionized Chunk Ticking
|
||||||
public final Thread mainThread;
|
public final Thread mainThread;
|
||||||
final ThreadedLevelLightEngine lightEngine;
|
final ThreadedLevelLightEngine lightEngine;
|
||||||
public final ServerChunkCache.MainThreadExecutor mainThreadProcessor;
|
public final ServerChunkCache.MainThreadExecutor mainThreadProcessor;
|
||||||
@@ -479,6 +480,41 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
@@ -479,6 +483,46 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
}
|
}
|
||||||
// CraftBukkit end
|
// CraftBukkit end
|
||||||
|
|
||||||
@@ -24,62 +27,84 @@ index 2678bf59d557f085c7265e2f3eb038647723d35e..ee4e5462c784ea8588c12eb2b248c708
|
|||||||
+ private static final int[] DX = {1, -1, 0, 0, 1, -1, -1, 1};
|
+ private static final int[] DX = {1, -1, 0, 0, 1, -1, -1, 1};
|
||||||
+ private static final int[] DZ = {0, 0, 1, -1, 1, 1, -1, -1};
|
+ private static final int[] DZ = {0, 0, 1, -1, 1, 1, -1, -1};
|
||||||
+
|
+
|
||||||
+ private List<List<LevelChunk>> splitChunksIntoRegions(List<LevelChunk> chunks) {
|
+ private List<LevelChunk>[] splitChunksIntoRegions(List<LevelChunk> chunks) {
|
||||||
+ Set<LevelChunk> chunkSet = new java.util.HashSet<>(chunks);
|
+ int size = chunks.size();
|
||||||
+ Set<LevelChunk> visited = new java.util.HashSet<>(chunks.size());
|
+ java.util.IdentityHashMap<LevelChunk, Boolean> chunkSet = new java.util.IdentityHashMap<>(size);
|
||||||
+ List<List<LevelChunk>> groups = new ArrayList<>();
|
|
||||||
+
|
+
|
||||||
+ for (LevelChunk chunk : chunks) {
|
+ for (LevelChunk chunk : chunks) {
|
||||||
+ if (visited.contains(chunk)) continue;
|
+ chunkSet.put(chunk, Boolean.TRUE);
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ List<LevelChunk> group = new ArrayList<>(64);
|
+ List<List<LevelChunk>> groups = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(size >> 3);
|
||||||
+ java.util.ArrayDeque<net.minecraft.world.level.chunk.LevelChunk> stack = new java.util.ArrayDeque<>();
|
+ LevelChunk[] stack = new LevelChunk[size];
|
||||||
+ stack.push(chunk);
|
+ int stackPointer = 0;
|
||||||
+ visited.add(chunk);
|
|
||||||
+
|
+
|
||||||
+ while (!stack.isEmpty()) {
|
+ for (LevelChunk chunk : chunks) {
|
||||||
+ LevelChunk current = stack.pop();
|
+ if (chunkSet.remove(chunk) == null) continue;
|
||||||
|
+
|
||||||
|
+ List<LevelChunk> group = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(64);
|
||||||
|
+ stack[stackPointer++] = chunk;
|
||||||
|
+
|
||||||
|
+ while (stackPointer > 0) {
|
||||||
|
+ LevelChunk current = stack[--stackPointer];
|
||||||
+ group.add(current);
|
+ group.add(current);
|
||||||
+
|
+
|
||||||
+ for (int i = 0; i < 8; i++) {
|
+ for (int i = 0; i < 8; i++) {
|
||||||
+ LevelChunk neighbor = getChunk(current.locX + DX[i], current.locZ + DZ[i], false);
|
+ LevelChunk neighbor = getChunk(current.locX + DX[i], current.locZ + DZ[i], false);
|
||||||
+ if (neighbor == null || !chunkSet.contains(neighbor) || !visited.add(neighbor)) continue;
|
+ if (neighbor == null || chunkSet.remove(neighbor) == null) continue;
|
||||||
+ stack.push(neighbor);
|
+ stack[stackPointer++] = neighbor;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ groups.add(group);
|
+ groups.add(group);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ return groups;
|
+ return groups.toArray(new List[0]);
|
||||||
+ }
|
+ }
|
||||||
+ // DivineMC end - Regionized Chunk Ticking
|
+ // DivineMC end - Regionized Chunk Ticking
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
public void tick(BooleanSupplier hasTimeLeft, boolean tickChunks) {
|
public void tick(BooleanSupplier hasTimeLeft, boolean tickChunks) {
|
||||||
ProfilerFiller profilerFiller = Profiler.get();
|
ProfilerFiller profilerFiller = Profiler.get();
|
||||||
@@ -519,7 +555,27 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
@@ -519,7 +563,44 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||||
this.shuffleRandom.setSeed(this.level.random.nextLong());
|
this.shuffleRandom.setSeed(this.level.random.nextLong());
|
||||||
if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
||||||
// Paper end - chunk tick iteration optimisation
|
// Paper end - chunk tick iteration optimisation
|
||||||
- this.tickChunks(profilerFiller, l, list);
|
- this.tickChunks(profilerFiller, l, list);
|
||||||
+ // DivineMC start - Regionized Chunk Ticking
|
+ // DivineMC start - Regionized Chunk Ticking
|
||||||
+ if (org.bxteam.divinemc.DivineConfig.enableRegionizedChunkTicking) {
|
+ if (org.bxteam.divinemc.DivineConfig.enableRegionizedChunkTicking) {
|
||||||
+ List<List<LevelChunk>> regions = splitChunksIntoRegions(list);
|
+ List<LevelChunk>[] regions = splitChunksIntoRegions(list);
|
||||||
+ List<CompletableFuture<Void>> futures = new ArrayList<>();
|
+ int regionCount = regions.length;
|
||||||
|
+ this.tickingRegionsCount = regionCount;
|
||||||
|
+ java.util.concurrent.CountDownLatch latch = new java.util.concurrent.CountDownLatch(regionCount);
|
||||||
|
+
|
||||||
|
+ try {
|
||||||
|
+ java.util.concurrent.ForkJoinPool.managedBlock(new java.util.concurrent.ForkJoinPool.ManagedBlocker() {
|
||||||
|
+ @Override
|
||||||
|
+ public boolean block() throws InterruptedException {
|
||||||
+ for (List<LevelChunk> region : regions) {
|
+ for (List<LevelChunk> region : regions) {
|
||||||
+ CompletableFuture<Void> future = new CompletableFuture<>();
|
+ if (region == null) continue;
|
||||||
+ futures.add(future);
|
|
||||||
+ REGION_EXECUTOR.execute(() -> {
|
+ REGION_EXECUTOR.execute(() -> {
|
||||||
+ try {
|
+ try {
|
||||||
+ tickChunks(profilerFiller, l, region);
|
+ tickChunks(profilerFiller, l, region);
|
||||||
+ } finally {
|
+ } finally {
|
||||||
+ future.complete(null);
|
+ latch.countDown();
|
||||||
+ }
|
+ }
|
||||||
+ });
|
+ });
|
||||||
+ }
|
+ }
|
||||||
+ CompletableFuture<Void> finalFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
+
|
||||||
+ finalFuture.join();
|
+ latch.await();
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean isReleasable() {
|
||||||
|
+ return latch.getCount() == 0;
|
||||||
|
+ }
|
||||||
|
+ });
|
||||||
|
+ } catch (InterruptedException ex) {
|
||||||
|
+ throw new RuntimeException("Interrupted managed block during region ticking", ex);
|
||||||
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ this.tickChunks(profilerFiller, l, list);
|
+ this.tickChunks(profilerFiller, l, list);
|
||||||
+ }
|
+ }
|
||||||
|
|||||||
@@ -7,34 +7,43 @@ Original author - Taiyou06
|
|||||||
Original patch - https://github.com/Winds-Studio/Leaf/pull/235
|
Original patch - https://github.com/Winds-Studio/Leaf/pull/235
|
||||||
|
|
||||||
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java
|
||||||
index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..515e90aca8ab1c3a9dce67784a360630ae7dd247 100644
|
index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f3a2cc99799b41d663940847f7099df0ba40c3b7 100644
|
||||||
--- a/net/minecraft/network/Connection.java
|
--- a/net/minecraft/network/Connection.java
|
||||||
+++ b/net/minecraft/network/Connection.java
|
+++ b/net/minecraft/network/Connection.java
|
||||||
@@ -85,7 +85,7 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
@@ -85,7 +85,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
private static final ProtocolInfo<ServerHandshakePacketListener> INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND;
|
private static final ProtocolInfo<ServerHandshakePacketListener> INITIAL_PROTOCOL = HandshakeProtocols.SERVERBOUND;
|
||||||
private final PacketFlow receiving;
|
private final PacketFlow receiving;
|
||||||
private volatile boolean sendLoginDisconnect = true;
|
private volatile boolean sendLoginDisconnect = true;
|
||||||
- private final Queue<WrappedConsumer> pendingActions = Queues.newConcurrentLinkedQueue(); // Paper - Optimize network
|
- private final Queue<WrappedConsumer> pendingActions = Queues.newConcurrentLinkedQueue(); // Paper - Optimize network
|
||||||
+ private final Queue<WrappedConsumer> pendingActions = new java.util.ArrayDeque<>(); // Paper - Optimize network // DivineMC - Optimize Connection.flushQueue
|
+ // DivineMC start - Optimize Connection.flushQueue
|
||||||
|
+ private final Queue<WrappedConsumer> pendingActions = org.bxteam.divinemc.DivineConfig.connectionFlushQueueRewrite
|
||||||
|
+ ? new java.util.ArrayDeque<>()
|
||||||
|
+ : Queues.newConcurrentLinkedQueue(); // Paper - Optimize network
|
||||||
|
+ // DivineMC end - Optimize Connection.flushQueue
|
||||||
public Channel channel;
|
public Channel channel;
|
||||||
public SocketAddress address;
|
public SocketAddress address;
|
||||||
// Spigot start
|
// Spigot start
|
||||||
@@ -541,10 +541,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
@@ -541,10 +545,16 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
if (io.papermc.paper.util.MCUtil.isMainThread()) {
|
if (io.papermc.paper.util.MCUtil.isMainThread()) {
|
||||||
return this.processQueue();
|
return this.processQueue();
|
||||||
} else if (this.isPending) {
|
} else if (this.isPending) {
|
||||||
- // Should only happen during login/status stages
|
- // Should only happen during login/status stages
|
||||||
- synchronized (this.pendingActions) {
|
- synchronized (this.pendingActions) {
|
||||||
- return this.processQueue();
|
- return this.processQueue();
|
||||||
- }
|
|
||||||
+ // DivineMC start - Optimize Connection.flushQueue
|
+ // DivineMC start - Optimize Connection.flushQueue
|
||||||
|
+ if (org.bxteam.divinemc.DivineConfig.connectionFlushQueueRewrite) {
|
||||||
+ this.channel.eventLoop().execute(this::processQueue);
|
+ this.channel.eventLoop().execute(this::processQueue);
|
||||||
+ return false;
|
+ return false;
|
||||||
|
+ } else {
|
||||||
|
+ synchronized (this.pendingActions) {
|
||||||
|
+ return this.processQueue();
|
||||||
|
+ }
|
||||||
|
}
|
||||||
+ // DivineMC end - Optimize Connection.flushQueue
|
+ // DivineMC end - Optimize Connection.flushQueue
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -554,29 +554,18 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
@@ -554,33 +564,53 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,29 +52,67 @@ index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..515e90aca8ab1c3a9dce67784a360630
|
|||||||
- final java.util.Iterator<WrappedConsumer> iterator = this.pendingActions.iterator();
|
- final java.util.Iterator<WrappedConsumer> iterator = this.pendingActions.iterator();
|
||||||
- while (iterator.hasNext()) {
|
- while (iterator.hasNext()) {
|
||||||
- final WrappedConsumer queued = iterator.next(); // poll -> peek
|
- final WrappedConsumer queued = iterator.next(); // poll -> peek
|
||||||
-
|
+ // DivineMC start - Optimize Connection.flushQueue
|
||||||
|
+ if (org.bxteam.divinemc.DivineConfig.connectionFlushQueueRewrite) {
|
||||||
|
+ WrappedConsumer queued;
|
||||||
|
+ while ((queued = this.pendingActions.poll()) != null) {
|
||||||
|
+ if (queued instanceof PacketSendAction packetSendAction) {
|
||||||
|
+ final Packet<?> packet = packetSendAction.packet;
|
||||||
|
+ if (!packet.isReady()) {
|
||||||
|
+ // Re-add to the front and exit
|
||||||
|
+ this.pendingActions.add(queued);
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
- // Fix NPE (Spigot bug caused by handleDisconnection())
|
- // Fix NPE (Spigot bug caused by handleDisconnection())
|
||||||
- if (queued == null) {
|
- if (queued == null) {
|
||||||
- return true;
|
- return true;
|
||||||
- }
|
+ if (queued.tryMarkConsumed()) {
|
||||||
-
|
+ queued.accept(this);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+ } else {
|
||||||
|
+ // If we are on main, we are safe here in that nothing else should be processing queue off main anymore
|
||||||
|
+ // But if we are not on main due to login/status, the parent is synchronized on packetQueue
|
||||||
|
+ final java.util.Iterator<WrappedConsumer> iterator = this.pendingActions.iterator();
|
||||||
|
+ while (iterator.hasNext()) {
|
||||||
|
+ final WrappedConsumer queued = iterator.next(); // poll -> peek
|
||||||
|
+
|
||||||
|
+ // Fix NPE (Spigot bug caused by handleDisconnection())
|
||||||
|
+ if (queued == null) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
|
||||||
- if (queued.isConsumed()) {
|
- if (queued.isConsumed()) {
|
||||||
- continue;
|
- continue;
|
||||||
- }
|
- }
|
||||||
-
|
+ if (queued.isConsumed()) {
|
||||||
+ // DivineMC start - Optimize Connection.flushQueue
|
+ continue;
|
||||||
+ WrappedConsumer queued;
|
+ }
|
||||||
+ while ((queued = this.pendingActions.poll()) != null) {
|
|
||||||
if (queued instanceof PacketSendAction packetSendAction) {
|
- if (queued instanceof PacketSendAction packetSendAction) {
|
||||||
final Packet<?> packet = packetSendAction.packet;
|
- final Packet<?> packet = packetSendAction.packet;
|
||||||
if (!packet.isReady()) {
|
- if (!packet.isReady()) {
|
||||||
+ this.pendingActions.add(queued);
|
- return false;
|
||||||
return false;
|
+ if (queued instanceof PacketSendAction packetSendAction) {
|
||||||
}
|
+ final Packet<?> packet = packetSendAction.packet;
|
||||||
|
+ if (!packet.isReady()) {
|
||||||
|
+ return false;
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
- }
|
||||||
|
|
||||||
- iterator.remove();
|
- iterator.remove();
|
||||||
+ // DivineMC end - Optimize Connection.flushQueue
|
- if (queued.tryMarkConsumed()) {
|
||||||
if (queued.tryMarkConsumed()) {
|
- queued.accept(this);
|
||||||
queued.accept(this);
|
+ iterator.remove();
|
||||||
|
+ if (queued.tryMarkConsumed()) {
|
||||||
|
+ queued.accept(this);
|
||||||
|
+ }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
+ // DivineMC end - Optimize Connection.flushQueue
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Paper end - Optimize network
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com>
|
||||||
|
Date: Wed, 5 Mar 2025 18:08:25 +0300
|
||||||
|
Subject: [PATCH] Configurable MC-59471
|
||||||
|
|
||||||
|
Bring back MC-59471, MC-129055 on 1.21.2+, which fixed in 1.21.2 snapshots 24w33a and 24w36a
|
||||||
|
|
||||||
|
P.S: This setting is different from skip-tripwire-hook-placement-validation in Paper
|
||||||
|
|
||||||
|
diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||||
|
index 9aace993c6c18f1a50610e4766225485984b8167..0849e0b116845a16792855afdd16de7ec6838542 100644
|
||||||
|
--- a/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||||
|
+++ b/net/minecraft/world/level/block/TripWireHookBlock.java
|
||||||
|
@@ -201,7 +201,6 @@ public class TripWireHookBlock extends Block {
|
||||||
|
if (!cancelledEmitterHook) { // Paper - Call BlockRedstoneEvent
|
||||||
|
emitState(level, pos, flag2, flag3, flag, flag1);
|
||||||
|
if (!attaching) {
|
||||||
|
- if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.skipTripwireHookPlacementValidation || level.getBlockState(pos).is(Blocks.TRIPWIRE_HOOK)) // Paper - Validate tripwire hook placement before update
|
||||||
|
level.setBlock(pos, blockState1.setValue(FACING, direction), 3);
|
||||||
|
if (shouldNotifyNeighbours) {
|
||||||
|
notifyNeighbors(block, level, pos, direction);
|
||||||
|
@@ -214,10 +213,17 @@ public class TripWireHookBlock extends Block {
|
||||||
|
BlockPos blockPos1 = pos.relative(direction, i2);
|
||||||
|
BlockState blockState2 = blockStates[i2];
|
||||||
|
if (blockState2 != null) {
|
||||||
|
- BlockState blockState3 = level.getBlockState(blockPos1);
|
||||||
|
- if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) {
|
||||||
|
- if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); // Paper - prevent tripwire from updating
|
||||||
|
+ // DivineMC start - Configurable MC-59471
|
||||||
|
+ if (level.divineConfig.allowTripwireDupe) {
|
||||||
|
+ level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3);
|
||||||
|
+ level.getBlockState(blockPos1);
|
||||||
|
+ } else {
|
||||||
|
+ BlockState blockState3 = level.getBlockState(blockPos1);
|
||||||
|
+ if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) {
|
||||||
|
+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); // Paper - prevent tripwire from updating
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
+ // DivineMC end - Configurable MC-59471
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -170,7 +170,7 @@ public class DivineConfig {
|
|||||||
public static long chunkDataCacheSoftLimit = 8192L;
|
public static long chunkDataCacheSoftLimit = 8192L;
|
||||||
public static long chunkDataCacheLimit = 32678L;
|
public static long chunkDataCacheLimit = 32678L;
|
||||||
public static int maxViewDistance = 32;
|
public static int maxViewDistance = 32;
|
||||||
public static ChunkSystemAlgorithms chunkWorkerAlgorithm = ChunkSystemAlgorithms.MOONRISE;
|
public static ChunkSystemAlgorithms chunkWorkerAlgorithm = ChunkSystemAlgorithms.C2ME;
|
||||||
public static int threadPoolPriority = Thread.NORM_PRIORITY + 1;
|
public static int threadPoolPriority = Thread.NORM_PRIORITY + 1;
|
||||||
public static boolean enableSecureSeed = false;
|
public static boolean enableSecureSeed = false;
|
||||||
public static boolean smoothBedrockLayer = false;
|
public static boolean smoothBedrockLayer = false;
|
||||||
@@ -286,7 +286,6 @@ public class DivineConfig {
|
|||||||
public static boolean ignoreMovedTooQuicklyWhenLagging = true;
|
public static boolean ignoreMovedTooQuicklyWhenLagging = true;
|
||||||
public static boolean alwaysAllowWeirdMovement = true;
|
public static boolean alwaysAllowWeirdMovement = true;
|
||||||
public static boolean updateSuppressionCrashFix = true;
|
public static boolean updateSuppressionCrashFix = true;
|
||||||
public static boolean disableDisconnectSpam = false;
|
|
||||||
private static void miscSettings() {
|
private static void miscSettings() {
|
||||||
skipUselessSecondaryPoiSensor = getBoolean("settings.misc.skip-useless-secondary-poi-sensor", skipUselessSecondaryPoiSensor);
|
skipUselessSecondaryPoiSensor = getBoolean("settings.misc.skip-useless-secondary-poi-sensor", skipUselessSecondaryPoiSensor);
|
||||||
clumpOrbs = getBoolean("settings.misc.clump-orbs", clumpOrbs,
|
clumpOrbs = getBoolean("settings.misc.clump-orbs", clumpOrbs,
|
||||||
@@ -296,8 +295,18 @@ public class DivineConfig {
|
|||||||
alwaysAllowWeirdMovement = getBoolean("settings.misc.always-allow-weird-movement", alwaysAllowWeirdMovement,
|
alwaysAllowWeirdMovement = getBoolean("settings.misc.always-allow-weird-movement", alwaysAllowWeirdMovement,
|
||||||
"Means ignoring messages like 'moved too quickly' and 'moved wrongly'");
|
"Means ignoring messages like 'moved too quickly' and 'moved wrongly'");
|
||||||
updateSuppressionCrashFix = getBoolean("settings.misc.update-suppression-crash-fix", updateSuppressionCrashFix);
|
updateSuppressionCrashFix = getBoolean("settings.misc.update-suppression-crash-fix", updateSuppressionCrashFix);
|
||||||
disableDisconnectSpam = getBoolean("settings.misc.disable-disconnect-spam", disableDisconnectSpam,
|
}
|
||||||
|
|
||||||
|
public static boolean disableDisconnectSpam = false;
|
||||||
|
public static boolean connectionFlushQueueRewrite = true;
|
||||||
|
private static void networkSettings() {
|
||||||
|
disableDisconnectSpam = getBoolean("settings.network.disable-disconnect-spam", disableDisconnectSpam,
|
||||||
"Prevents players being disconnected by 'disconnect.spam' when sending too many chat packets");
|
"Prevents players being disconnected by 'disconnect.spam' when sending too many chat packets");
|
||||||
|
connectionFlushQueueRewrite = getBoolean("settings.network.connection-flush-queue-rewrite", connectionFlushQueueRewrite,
|
||||||
|
"Replaces ConcurrentLinkedQueue with ArrayDeque in Connection for better performance",
|
||||||
|
"and also uses the Netty event loop to ensure thread safety.",
|
||||||
|
"",
|
||||||
|
"Note: May increase the Netty thread usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean enableFasterTntOptimization = true;
|
public static boolean enableFasterTntOptimization = true;
|
||||||
@@ -359,6 +368,8 @@ public class DivineConfig {
|
|||||||
public static boolean virtualTabCompleteScheduler = false;
|
public static boolean virtualTabCompleteScheduler = false;
|
||||||
public static boolean virtualAsyncExecutor = false;
|
public static boolean virtualAsyncExecutor = false;
|
||||||
public static boolean virtualCommandBuilderScheduler = false;
|
public static boolean virtualCommandBuilderScheduler = false;
|
||||||
|
public static boolean virtualProfileLookupPool = false;
|
||||||
|
public static boolean virtualServerTextFilterPool = false;
|
||||||
private static void virtualThreads() {
|
private static void virtualThreads() {
|
||||||
virtualThreadsEnabled = getBoolean("settings.virtual-threads.enabled", virtualThreadsEnabled,
|
virtualThreadsEnabled = getBoolean("settings.virtual-threads.enabled", virtualThreadsEnabled,
|
||||||
"Enables use of virtual threads that was added in Java 21");
|
"Enables use of virtual threads that was added in Java 21");
|
||||||
@@ -375,6 +386,10 @@ public class DivineConfig {
|
|||||||
"Uses virtual threads for the MCUtil async executor.");
|
"Uses virtual threads for the MCUtil async executor.");
|
||||||
virtualCommandBuilderScheduler = getBoolean("settings.virtual-threads.command-builder-scheduler", virtualCommandBuilderScheduler,
|
virtualCommandBuilderScheduler = getBoolean("settings.virtual-threads.command-builder-scheduler", virtualCommandBuilderScheduler,
|
||||||
"Uses virtual threads for the Async Command Builder Thread Pool.");
|
"Uses virtual threads for the Async Command Builder Thread Pool.");
|
||||||
|
virtualProfileLookupPool = getBoolean("settings.virtual-threads.profile-lookup-pool", virtualProfileLookupPool,
|
||||||
|
"Uses virtual threads for the Profile Lookup Pool, that is used for fetching player profiles.");
|
||||||
|
virtualServerTextFilterPool = getBoolean("settings.virtual-threads.server-text-filter-pool", virtualServerTextFilterPool,
|
||||||
|
"Uses virtual threads for the server text filter pool.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean asyncPathfinding = true;
|
public static boolean asyncPathfinding = true;
|
||||||
|
|||||||
@@ -59,7 +59,11 @@ public class DivineWorldConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean allowEntityPortalWithPassenger = true;
|
public boolean allowEntityPortalWithPassenger = true;
|
||||||
|
public boolean allowTripwireDupe = false;
|
||||||
private void unsupportedFeatures() {
|
private void unsupportedFeatures() {
|
||||||
allowEntityPortalWithPassenger = getBoolean("unsupported-features.allow-entity-portal-with-passenger", allowEntityPortalWithPassenger);
|
allowEntityPortalWithPassenger = getBoolean("unsupported-features.allow-entity-portal-with-passenger", allowEntityPortalWithPassenger,
|
||||||
|
"Enables or disables the fix of MC-67 bug: https://bugs-legacy.mojang.com/browse/MC-67");
|
||||||
|
allowTripwireDupe = getBoolean("unsupported-features.allow-tripwire-dupe", allowTripwireDupe,
|
||||||
|
"Bring back MC-59471, MC-129055 on 1.21.2+, which fixed in 1.21.2 snapshots 24w33a and 24w36a");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user