diff --git a/leaf-server/minecraft-patches/features/0111-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch b/leaf-server/minecraft-patches/features/0110-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0111-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch rename to leaf-server/minecraft-patches/features/0110-PaperPR-Fix-MC-117075-Block-Entities-Unload-Lag-Spik.patch diff --git a/leaf-server/minecraft-patches/features/0112-Sepals-Rearrange-the-attackable-conditions.patch b/leaf-server/minecraft-patches/features/0111-Sepals-Rearrange-the-attackable-conditions.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0112-Sepals-Rearrange-the-attackable-conditions.patch rename to leaf-server/minecraft-patches/features/0111-Sepals-Rearrange-the-attackable-conditions.patch diff --git a/leaf-server/minecraft-patches/features/0113-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch b/leaf-server/minecraft-patches/features/0112-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0113-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch rename to leaf-server/minecraft-patches/features/0112-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch diff --git a/leaf-server/minecraft-patches/features/0114-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch b/leaf-server/minecraft-patches/features/0113-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0114-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch rename to leaf-server/minecraft-patches/features/0113-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch diff --git a/leaf-server/minecraft-patches/features/0115-Optimize-checking-nearby-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0114-Optimize-checking-nearby-players-for-spawning.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0115-Optimize-checking-nearby-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0114-Optimize-checking-nearby-players-for-spawning.patch diff --git a/leaf-server/minecraft-patches/features/0116-Cache-supporting-block-check.patch b/leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0116-Cache-supporting-block-check.patch rename to leaf-server/minecraft-patches/features/0115-Cache-supporting-block-check.patch diff --git a/leaf-server/minecraft-patches/features/0117-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch b/leaf-server/minecraft-patches/features/0116-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0117-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch rename to leaf-server/minecraft-patches/features/0116-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch diff --git a/leaf-server/minecraft-patches/features/0118-Replace-brain-activity-maps-with-optimized-collectio.patch b/leaf-server/minecraft-patches/features/0117-Replace-brain-activity-maps-with-optimized-collectio.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0118-Replace-brain-activity-maps-with-optimized-collectio.patch rename to leaf-server/minecraft-patches/features/0117-Replace-brain-activity-maps-with-optimized-collectio.patch diff --git a/leaf-server/minecraft-patches/features/0119-Remove-stream-in-villagers.patch b/leaf-server/minecraft-patches/features/0118-Remove-stream-in-villagers.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0119-Remove-stream-in-villagers.patch rename to leaf-server/minecraft-patches/features/0118-Remove-stream-in-villagers.patch diff --git a/leaf-server/minecraft-patches/features/0120-Optimize-baby-villager-sensor.patch b/leaf-server/minecraft-patches/features/0119-Optimize-baby-villager-sensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0120-Optimize-baby-villager-sensor.patch rename to leaf-server/minecraft-patches/features/0119-Optimize-baby-villager-sensor.patch diff --git a/leaf-server/minecraft-patches/features/0121-Only-player-pushable.patch b/leaf-server/minecraft-patches/features/0120-Only-player-pushable.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0121-Only-player-pushable.patch rename to leaf-server/minecraft-patches/features/0120-Only-player-pushable.patch diff --git a/leaf-server/minecraft-patches/features/0122-Remove-iterators-from-Inventory-contains.patch b/leaf-server/minecraft-patches/features/0121-Remove-iterators-from-Inventory-contains.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0122-Remove-iterators-from-Inventory-contains.patch rename to leaf-server/minecraft-patches/features/0121-Remove-iterators-from-Inventory-contains.patch diff --git a/leaf-server/minecraft-patches/features/0123-Alternative-Brain-Behaviour.patch b/leaf-server/minecraft-patches/features/0122-Alternative-Brain-Behaviour.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0123-Alternative-Brain-Behaviour.patch rename to leaf-server/minecraft-patches/features/0122-Alternative-Brain-Behaviour.patch diff --git a/leaf-server/minecraft-patches/features/0124-Cache-eligible-players-for-despawn-checks.patch b/leaf-server/minecraft-patches/features/0123-Cache-eligible-players-for-despawn-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0124-Cache-eligible-players-for-despawn-checks.patch rename to leaf-server/minecraft-patches/features/0123-Cache-eligible-players-for-despawn-checks.patch diff --git a/leaf-server/minecraft-patches/features/0125-Slightly-optimise-getNearestPlayer.patch b/leaf-server/minecraft-patches/features/0124-Slightly-optimise-getNearestPlayer.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0125-Slightly-optimise-getNearestPlayer.patch rename to leaf-server/minecraft-patches/features/0124-Slightly-optimise-getNearestPlayer.patch diff --git a/leaf-server/minecraft-patches/features/0110-Rewrite-queue-on-Connection.flushQueue.patch b/leaf-server/minecraft-patches/features/0125-Rewrite-queue-on-Connection.flushQueue.patch similarity index 81% rename from leaf-server/minecraft-patches/features/0110-Rewrite-queue-on-Connection.flushQueue.patch rename to leaf-server/minecraft-patches/features/0125-Rewrite-queue-on-Connection.flushQueue.patch index bab32acf..3f23cf60 100644 --- a/leaf-server/minecraft-patches/features/0110-Rewrite-queue-on-Connection.flushQueue.patch +++ b/leaf-server/minecraft-patches/features/0125-Rewrite-queue-on-Connection.flushQueue.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Rewrite queue on Connection.flushQueue diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f4e535f3f7e9bcb6f0383e4704b8012cde7717a3 100644 +index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..eb9d99d657ae01c36af7cf4a75e206b917a14c39 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -35,6 +35,7 @@ import io.netty.handler.timeout.TimeoutException; @@ -21,11 +21,11 @@ index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f4e535f3f7e9bcb6f0383e4704b8012c private final PacketFlow receiving; private volatile boolean sendLoginDisconnect = true; - private final Queue pendingActions = Queues.newConcurrentLinkedQueue(); // Paper - Optimize network -+ private final Queue pendingActions = new ArrayDeque<>(); // Paper - Optimize network - Leaf optimize queue ++ private final Queue pendingActions = new ArrayDeque<>(); // Paper - Optimize network // Leaf - Rewrite queue on Connection.flushQueue public Channel channel; public SocketAddress address; // Spigot start -@@ -541,10 +542,9 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -541,10 +542,11 @@ public class Connection extends SimpleChannelInboundHandler> { if (io.papermc.paper.util.MCUtil.isMainThread()) { return this.processQueue(); } else if (this.isPending) { @@ -33,13 +33,15 @@ index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f4e535f3f7e9bcb6f0383e4704b8012c - synchronized (this.pendingActions) { - return this.processQueue(); - } ++ // Leaf start - Rewrite queue on Connection.flushQueue + // Submit to the event loop to ensure thread confinement -+ this.channel.eventLoop().execute(() -> this.processQueue()); ++ this.channel.eventLoop().execute(this::processQueue); + return false; ++ // Leaf end - Rewrite queue on Connection.flushQueue } return false; } -@@ -554,29 +554,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -554,29 +556,19 @@ public class Connection extends SimpleChannelInboundHandler> { return true; } @@ -58,6 +60,7 @@ index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f4e535f3f7e9bcb6f0383e4704b8012c - continue; - } - ++ // Leaf start - Rewrite queue on Connection.flushQueue + WrappedConsumer queued; + while ((queued = this.pendingActions.poll()) != null) { if (queued instanceof PacketSendAction packetSendAction) { @@ -70,6 +73,7 @@ index 7b78c0af4a83bd39a5bc2d6554cc677bd4c0c822..f4e535f3f7e9bcb6f0383e4704b8012c } - iterator.remove(); ++ // Leaf end - Rewrite queue on Connection.flushQueue if (queued.tryMarkConsumed()) { queued.accept(this); }