From bcec5b11e6728f3eb3078aa4fcc8e87f3d545ec2 Mon Sep 17 00:00:00 2001 From: Lukas Alt Date: Thu, 27 Apr 2023 20:50:14 +0200 Subject: [PATCH] Fixed large packet handling (#9147) Co-authored-by: Shane Freeder --- ...e-Large-Packets-disconnecting-client.patch | 24 ++++++++++++++----- .../0290-Add-PlayerConnectionCloseEvent.patch | 4 ++-- ...-Manager-and-add-advanced-packet-sup.patch | 18 +++++++------- ...ktraces-in-log-messages-crash-report.patch | 4 ++-- .../server/0465-Buffer-joins-to-world.patch | 4 ++-- .../server/0500-Add-API-for-quit-reason.patch | 4 ++-- ...Add-Channel-initialization-listeners.patch | 6 ++--- ...trolled-flushing-for-network-manager.patch | 16 ++++++------- ...l-more-information-in-watchdog-dumps.patch | 4 ++-- .../0708-Add-packet-limiter-config.patch | 4 ++-- ...18-Optimise-non-flush-packet-sending.patch | 4 ++-- ...ocity-compression-and-cipher-natives.patch | 8 +++---- 12 files changed, 56 insertions(+), 44 deletions(-) diff --git a/patches/server/0286-Handle-Large-Packets-disconnecting-client.patch b/patches/server/0286-Handle-Large-Packets-disconnecting-client.patch index 96714b8afe..4924f6eb7f 100644 --- a/patches/server/0286-Handle-Large-Packets-disconnecting-client.patch +++ b/patches/server/0286-Handle-Large-Packets-disconnecting-client.patch @@ -7,16 +7,19 @@ If a players inventory is too big to send in a single packet, split the inventory set into multiple packets instead. diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index b1a9c75081f7e61212ea9395b35375e067fd7fc6..f70d81e1a779da840b636b36a913a0dca9427c94 100644 +index b1a9c75081f7e61212ea9395b35375e067fd7fc6..6f903ad884db68f654a9f2501e336123699c11a3 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -152,6 +152,15 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -152,6 +152,18 @@ public class Connection extends SimpleChannelInboundHandler> { } public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { + // Paper start -+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) { -+ if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) { ++ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException packetTooLargeException) { ++ if (packetTooLargeException.getPacket().packetTooLarge(this)) { ++ return; ++ } else if (packetTooLargeException.getPacket().isSkippable()) { ++ Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); + return; + } else { + throwable = throwable.getCause(); @@ -27,9 +30,18 @@ index b1a9c75081f7e61212ea9395b35375e067fd7fc6..f70d81e1a779da840b636b36a913a0dc Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); } else { diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java -index 42828edf81bd475b673a9d143f79c0d0711f14f5..ebee957fb048da6ffcd2a5ba2ed989ed1a6634e9 100644 +index 42828edf81bd475b673a9d143f79c0d0711f14f5..fbfadeb83719b81f42724e79c59e92ed88fdece7 100644 --- a/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java +@@ -40,7 +40,7 @@ public class PacketEncoder extends MessageToByteEncoder> { + int j = friendlyByteBuf.writerIndex(); + packet.write(friendlyByteBuf); + int k = friendlyByteBuf.writerIndex() - j; +- if (k > 8388608) { ++ if (false && k > 8388608) { // Paper - disable + throw new IllegalArgumentException("Packet too big (is " + k + ", should be less than 8388608): " + packet); + } else { + int l = channelHandlerContext.channel().attr(Connection.ATTRIBUTE_PROTOCOL).get().getId(); @@ -54,7 +54,31 @@ public class PacketEncoder extends MessageToByteEncoder> { throw var10; } @@ -46,7 +58,7 @@ index 42828edf81bd475b673a9d143f79c0d0711f14f5..ebee957fb048da6ffcd2a5ba2ed989ed } + + // Paper start -+ private static int MAX_PACKET_SIZE = 2097152; ++ private static int MAX_PACKET_SIZE = 8388608; + + public static class PacketTooLargeException extends RuntimeException { + private final Packet packet; diff --git a/patches/server/0290-Add-PlayerConnectionCloseEvent.patch b/patches/server/0290-Add-PlayerConnectionCloseEvent.patch index 34fbbdfdf1..763365915d 100644 --- a/patches/server/0290-Add-PlayerConnectionCloseEvent.patch +++ b/patches/server/0290-Add-PlayerConnectionCloseEvent.patch @@ -39,10 +39,10 @@ public net.minecraft.server.network.ServerLoginPacketListenerImpl state public net.minecraft.server.network.ServerLoginPacketListenerImpl gameProfile diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index f70d81e1a779da840b636b36a913a0dca9427c94..62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa 100644 +index 6f903ad884db68f654a9f2501e336123699c11a3..e1eea381a2ebcc32424d31c42a45287d2a1cb16a 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -487,6 +487,26 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -490,6 +490,26 @@ public class Connection extends SimpleChannelInboundHandler> { this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic")); } this.queue.clear(); // Free up packet queue. diff --git a/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch b/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch index f7ccd1df96..ebce2c9397 100644 --- a/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch +++ b/patches/server/0301-Optimize-Network-Manager-and-add-advanced-packet-sup.patch @@ -28,7 +28,7 @@ and then catch exceptions and close if they fire. Part of this commit was authored by: Spottedleaf, sandtechnology diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc29449cf5c 100644 +index e1eea381a2ebcc32424d31c42a45287d2a1cb16a..ca9a36e357e73b1b518ebb5c937314269655de32 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -118,6 +118,10 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -50,7 +50,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 this.channel.attr(Connection.ATTRIBUTE_PROTOCOL).set(state); this.channel.attr(BundlerInfo.BUNDLER_PROVIDER).set(state); this.channel.config().setAutoRead(true); -@@ -220,19 +225,88 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -223,19 +228,88 @@ public class Connection extends SimpleChannelInboundHandler> { Validate.notNull(listener, "packetListener", new Object[0]); this.packetListener = listener; } @@ -143,7 +143,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 } private void sendPacket(Packet packet, @Nullable PacketSendListener callbacks) { -@@ -264,6 +338,15 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -267,6 +341,15 @@ public class Connection extends SimpleChannelInboundHandler> { this.setProtocol(packetState); } @@ -159,7 +159,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 ChannelFuture channelfuture = this.channel.writeAndFlush(packet); if (callbacks != null) { -@@ -282,28 +365,72 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -285,28 +368,72 @@ public class Connection extends SimpleChannelInboundHandler> { }); } @@ -240,7 +240,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 } finally { // Paper start - add pending task queue Runnable r; while ((r = this.pendingTasks.poll()) != null) { -@@ -311,6 +438,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -314,6 +441,7 @@ public class Connection extends SimpleChannelInboundHandler> { } } // Paper end - add pending task queue } @@ -248,7 +248,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 public void tick() { this.flushQueue(); -@@ -347,9 +475,22 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -350,9 +478,22 @@ public class Connection extends SimpleChannelInboundHandler> { return this.address; } @@ -271,7 +271,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 // Spigot End if (this.channel.isOpen()) { this.channel.close(); // We can't wait as this may be called from an event loop. -@@ -478,7 +619,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -481,7 +622,7 @@ public class Connection extends SimpleChannelInboundHandler> { public void handleDisconnection() { if (this.channel != null && !this.channel.isOpen()) { if (this.disconnectionHandled) { @@ -280,7 +280,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 } else { this.disconnectionHandled = true; if (this.getDisconnectedReason() != null) { -@@ -486,7 +627,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -489,7 +630,7 @@ public class Connection extends SimpleChannelInboundHandler> { } else if (this.getPacketListener() != null) { this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic")); } @@ -289,7 +289,7 @@ index 62ee5e32ac0f5d244fa55f9fe45d34cf4d2becaa..184f36a137ed5e5cd20797e131801bc2 // Paper start - Add PlayerConnectionCloseEvent final PacketListener packetListener = this.getPacketListener(); if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) { -@@ -526,6 +667,18 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -529,6 +670,18 @@ public class Connection extends SimpleChannelInboundHandler> { @Nullable final PacketSendListener listener; diff --git a/patches/server/0396-Deobfuscate-stacktraces-in-log-messages-crash-report.patch b/patches/server/0396-Deobfuscate-stacktraces-in-log-messages-crash-report.patch index 92d371555e..be3feddf50 100644 --- a/patches/server/0396-Deobfuscate-stacktraces-in-log-messages-crash-report.patch +++ b/patches/server/0396-Deobfuscate-stacktraces-in-log-messages-crash-report.patch @@ -474,7 +474,7 @@ index 52eb3176437113f9a0ff85d10ce5c2415e1b5570..b54ddd0ba0b001fbcb1838a838ca4890 } } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 184f36a137ed5e5cd20797e131801bc29449cf5c..d3b5039adaa91fa254a582f030b33276c68fca0d 100644 +index ca9a36e357e73b1b518ebb5c937314269655de32..59bb1d340e0be6f15a8c6ac21500cdd909c18a8b 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -64,13 +64,13 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -494,7 +494,7 @@ index 184f36a137ed5e5cd20797e131801bc29449cf5c..d3b5039adaa91fa254a582f030b33276 }); private final PacketFlow receiving; private final Queue queue = Queues.newConcurrentLinkedQueue(); -@@ -196,7 +196,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -199,7 +199,7 @@ public class Connection extends SimpleChannelInboundHandler> { } } diff --git a/patches/server/0465-Buffer-joins-to-world.patch b/patches/server/0465-Buffer-joins-to-world.patch index f20edf45f4..28ead4089b 100644 --- a/patches/server/0465-Buffer-joins-to-world.patch +++ b/patches/server/0465-Buffer-joins-to-world.patch @@ -8,10 +8,10 @@ the world per tick, this attempts to reduce the impact that join floods has on the server diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index d3b5039adaa91fa254a582f030b33276c68fca0d..e4c471ad111efb40a820670328b67ac28c79bff0 100644 +index 59bb1d340e0be6f15a8c6ac21500cdd909c18a8b..ecc075d22b24f9e70cd3751c9ceea84b903020ae 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -440,14 +440,29 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -443,14 +443,29 @@ public class Connection extends SimpleChannelInboundHandler> { } // Paper end diff --git a/patches/server/0500-Add-API-for-quit-reason.patch b/patches/server/0500-Add-API-for-quit-reason.patch index c5b7d5c960..64bd874a12 100644 --- a/patches/server/0500-Add-API-for-quit-reason.patch +++ b/patches/server/0500-Add-API-for-quit-reason.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add API for quit reason diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index e4c471ad111efb40a820670328b67ac28c79bff0..6ef3a08ea5223ee28dd175d66c6405efe5517993 100644 +index ecc075d22b24f9e70cd3751c9ceea84b903020ae..90dd5a5c3ac94782483f99165bb3ddc85c179aae 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -173,12 +173,15 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -176,12 +176,15 @@ public class Connection extends SimpleChannelInboundHandler> { this.handlingFault = true; if (this.channel.isOpen()) { diff --git a/patches/server/0606-Add-Channel-initialization-listeners.patch b/patches/server/0606-Add-Channel-initialization-listeners.patch index 4e452715a9..4bbe9f2781 100644 --- a/patches/server/0606-Add-Channel-initialization-listeners.patch +++ b/patches/server/0606-Add-Channel-initialization-listeners.patch @@ -122,10 +122,10 @@ index 0000000000000000000000000000000000000000..0d7e7db9e37ef0183c32b217bd944fb4 + COMPRESSION_DISABLED +} diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 6ef3a08ea5223ee28dd175d66c6405efe5517993..3cee24bfb1b3a21b0da1b57e161afd8009942272 100644 +index 90dd5a5c3ac94782483f99165bb3ddc85c179aae..1404389f16cb6ed8bb1b2dad35e364b1428810a4 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -622,6 +622,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -625,6 +625,7 @@ public class Connection extends SimpleChannelInboundHandler> { } else { this.channel.pipeline().addBefore("encoder", "compress", new CompressionEncoder(compressionThreshold)); } @@ -133,7 +133,7 @@ index 6ef3a08ea5223ee28dd175d66c6405efe5517993..3cee24bfb1b3a21b0da1b57e161afd80 } else { if (this.channel.pipeline().get("decompress") instanceof CompressionDecoder) { this.channel.pipeline().remove("decompress"); -@@ -630,6 +631,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -633,6 +634,7 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.channel.pipeline().get("compress") instanceof CompressionEncoder) { this.channel.pipeline().remove("compress"); } diff --git a/patches/server/0697-Allow-controlled-flushing-for-network-manager.patch b/patches/server/0697-Allow-controlled-flushing-for-network-manager.patch index 7947f2478a..77361f9f13 100644 --- a/patches/server/0697-Allow-controlled-flushing-for-network-manager.patch +++ b/patches/server/0697-Allow-controlled-flushing-for-network-manager.patch @@ -9,7 +9,7 @@ This patch will be used to optimise out flush calls in later patches. diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d41fc4bdf8 100644 +index 1404389f16cb6ed8bb1b2dad35e364b1428810a4..d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -124,6 +124,39 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -52,7 +52,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 public Connection(PacketFlow side) { this.receiving = side; } -@@ -289,7 +322,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -292,7 +325,7 @@ public class Connection extends SimpleChannelInboundHandler> { io.papermc.paper.util.MCUtil.isMainThread() && packet.isReady() && this.queue.isEmpty() && (packet.getExtraPackets() == null || packet.getExtraPackets().isEmpty()) ))) { @@ -61,7 +61,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 return; } // write the packets to the queue, then flush - antixray hooks there already -@@ -313,6 +346,14 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -316,6 +349,14 @@ public class Connection extends SimpleChannelInboundHandler> { } private void sendPacket(Packet packet, @Nullable PacketSendListener callbacks) { @@ -76,7 +76,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 ConnectionProtocol enumprotocol = ConnectionProtocol.getProtocolForPacket(packet); ConnectionProtocol enumprotocol1 = this.getCurrentProtocol(); -@@ -327,16 +368,21 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -330,16 +371,21 @@ public class Connection extends SimpleChannelInboundHandler> { } if (this.channel.eventLoop().inEventLoop()) { @@ -100,7 +100,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 if (packetState != currentState) { this.setProtocol(packetState); } -@@ -350,7 +396,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -353,7 +399,7 @@ public class Connection extends SimpleChannelInboundHandler> { try { // Paper end @@ -109,7 +109,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 if (callbacks != null) { channelfuture.addListener((future) -> { -@@ -406,6 +452,10 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -409,6 +455,10 @@ public class Connection extends SimpleChannelInboundHandler> { private boolean processQueue() { try { // Paper - add pending task queue if (this.queue.isEmpty()) return true; @@ -120,7 +120,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 // 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 java.util.Iterator iterator = this.queue.iterator(); -@@ -413,7 +463,7 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -416,7 +466,7 @@ public class Connection extends SimpleChannelInboundHandler> { PacketHolder queued = iterator.next(); // poll -> peek // Fix NPE (Spigot bug caused by handleDisconnection()) @@ -129,7 +129,7 @@ index 3cee24bfb1b3a21b0da1b57e161afd8009942272..e2f28c9c51f30b0e2b22055bb10899d4 return true; } -@@ -425,11 +475,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -428,11 +478,17 @@ public class Connection extends SimpleChannelInboundHandler> { Packet packet = queued.packet; if (!packet.isReady()) { diff --git a/patches/server/0703-Detail-more-information-in-watchdog-dumps.patch b/patches/server/0703-Detail-more-information-in-watchdog-dumps.patch index 77f25b0622..ba485df6d7 100644 --- a/patches/server/0703-Detail-more-information-in-watchdog-dumps.patch +++ b/patches/server/0703-Detail-more-information-in-watchdog-dumps.patch @@ -7,10 +7,10 @@ Subject: [PATCH] Detail more information in watchdog dumps - Dump player name, player uuid, position, and world for packet handling diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index e2f28c9c51f30b0e2b22055bb10899d41fc4bdf8..2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd 100644 +index d7dd0b806d8d8e3f04f165a2b29097a5c1bcd199..b967c24e9ace2b6539e94bcc63b69e0c934a72be 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -519,7 +519,13 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -522,7 +522,13 @@ public class Connection extends SimpleChannelInboundHandler> { if (!(this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginPacketListener) || loginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT || Connection.joinAttemptsThisTick++ < MAX_PER_TICK) { diff --git a/patches/server/0708-Add-packet-limiter-config.patch b/patches/server/0708-Add-packet-limiter-config.patch index 6f60c2dbc0..cc497d052a 100644 --- a/patches/server/0708-Add-packet-limiter-config.patch +++ b/patches/server/0708-Add-packet-limiter-config.patch @@ -24,7 +24,7 @@ and an action can be defined: DROP or KICK If interval or rate are less-than 0, the limit is ignored diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd..f7ab5db5f5301d6efee1141f7725548eded2ed74 100644 +index b967c24e9ace2b6539e94bcc63b69e0c934a72be..ed27a0eb28b39f045064432107a86efc3b5927cd 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -156,6 +156,22 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -50,7 +50,7 @@ index 2ff278d085b25f40c1bdf0cc0cb564fb441ae1cd..f7ab5db5f5301d6efee1141f7725548e public Connection(PacketFlow side) { this.receiving = side; -@@ -237,6 +253,45 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -240,6 +256,45 @@ public class Connection extends SimpleChannelInboundHandler> { protected void channelRead0(ChannelHandlerContext channelhandlercontext, Packet packet) { if (this.channel.isOpen()) { diff --git a/patches/server/0718-Optimise-non-flush-packet-sending.patch b/patches/server/0718-Optimise-non-flush-packet-sending.patch index e1b5f25eb0..d0ec3959b9 100644 --- a/patches/server/0718-Optimise-non-flush-packet-sending.patch +++ b/patches/server/0718-Optimise-non-flush-packet-sending.patch @@ -20,7 +20,7 @@ up on this optimisation before he came along. Locally this patch drops the entity tracker tick by a full 1.5x. diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index f7ab5db5f5301d6efee1141f7725548eded2ed74..398af26a2408916fda3e71e887bbb73994727bc7 100644 +index ed27a0eb28b39f045064432107a86efc3b5927cd..9b46c1068b7b52f735423fc255ae6e949dd5cb0b 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java @@ -48,6 +48,8 @@ import org.slf4j.Logger; @@ -32,7 +32,7 @@ index f7ab5db5f5301d6efee1141f7725548eded2ed74..398af26a2408916fda3e71e887bbb739 public class Connection extends SimpleChannelInboundHandler> { private static final float AVERAGE_PACKETS_SMOOTHING = 0.75F; -@@ -425,9 +427,19 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -428,9 +430,19 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.channel.eventLoop().inEventLoop()) { this.doSendPacket(packet, callbacks, enumprotocol, enumprotocol1, flush); // Paper } else { diff --git a/patches/server/0721-Use-Velocity-compression-and-cipher-natives.patch b/patches/server/0721-Use-Velocity-compression-and-cipher-natives.patch index 388e86d2ed..e7761e7d84 100644 --- a/patches/server/0721-Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/0721-Use-Velocity-compression-and-cipher-natives.patch @@ -268,10 +268,10 @@ index 792883afe53d2b7989c25a81c2f9a639d5e21d20..c04379ca8a4db0f4de46ad2b3b338431 return this.threshold; } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java -index 398af26a2408916fda3e71e887bbb73994727bc7..fa1d325034dafdb9f1da546a6f9c5e88d2b67749 100644 +index 9b46c1068b7b52f735423fc255ae6e949dd5cb0b..f9e10bf048929886db3c414038d2c7e9f84226a6 100644 --- a/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java -@@ -707,11 +707,28 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -710,11 +710,28 @@ public class Connection extends SimpleChannelInboundHandler> { return networkmanager; } @@ -304,7 +304,7 @@ index 398af26a2408916fda3e71e887bbb73994727bc7..fa1d325034dafdb9f1da546a6f9c5e88 public boolean isEncrypted() { return this.encrypted; -@@ -740,16 +757,17 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -743,16 +760,17 @@ public class Connection extends SimpleChannelInboundHandler> { public void setupCompression(int compressionThreshold, boolean rejectsBadPackets) { if (compressionThreshold >= 0) { @@ -341,7 +341,7 @@ index 838244e3680ea6020701e10bafbde7f52976eaa1..e5e2f763d9b4b955df79ea0c4c79565b protected void initChannel(Channel channel) { try { diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 5ae5c35ee4d058bde6726797abb1472ee0516256..471e21f9e1f3ad6302e647d26a44b521fece223b 100644 +index b026c003e1fc02a9ea426f3126acb788fc09a874..595779cfd0ee1c405d7936f00a7cae1706125e7f 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java @@ -265,12 +265,14 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,