From 540d970a4d59faeee5c7c2e6e417254b5ed37b46 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Tue, 6 Jul 2021 07:32:13 +0000 Subject: [PATCH] Minecraft 1.17.1 support (#530) --- .../api/network/ProtocolVersion.java | 3 +- .../com/velocitypowered/proxy/Velocity.java | 11 ------ .../netty/MinecraftCompressDecoder.java | 2 +- .../MinecraftCompressorAndLengthEncoder.java | 35 ++----------------- 4 files changed, 6 insertions(+), 45 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java index 0bbdc45bb..bdddd586d 100644 --- a/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java +++ b/api/src/main/java/com/velocitypowered/api/network/ProtocolVersion.java @@ -54,7 +54,8 @@ public enum ProtocolVersion { MINECRAFT_1_16_2(751, "1.16.2"), MINECRAFT_1_16_3(753, "1.16.3"), MINECRAFT_1_16_4(754, "1.16.4", "1.16.5"), - MINECRAFT_1_17(755, "1.17"); + MINECRAFT_1_17(755, "1.17"), + MINECRAFT_1_17_1(756, "1.17.1"); private static final int SNAPSHOT_BIT = 30; diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 2362a4df7..25b3a7c47 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -35,17 +35,6 @@ public class Velocity { // How inconvenient. Force AWT to work with its head chopped off. System.setProperty("java.awt.headless", "true"); - // By default, Netty allocates 16MiB arenas for the PooledByteBufAllocator. This is too much - // memory for Minecraft, which imposes a maximum packet size of 2MiB! We'll use 4MiB as a more - // sane default. - // - // Note: io.netty.allocator.pageSize << io.netty.allocator.maxOrder is the formula used to - // compute the chunk size. We lower maxOrder from its default of 11 to 9. (We also use a null - // check, so that the user is free to choose another setting if need be.) - if (System.getProperty("io.netty.allocator.maxOrder") == null) { - System.setProperty("io.netty.allocator.maxOrder", "9"); - } - // If Velocity's natives are being extracted to a different temporary directory, make sure the // Netty natives are extracted there as well if (System.getProperty("velocity.natives-tmpdir") != null) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java index ccadf9d72..82fb4c153 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressDecoder.java @@ -30,7 +30,7 @@ import java.util.List; public class MinecraftCompressDecoder extends MessageToMessageDecoder { - private static final int VANILLA_MAXIMUM_UNCOMPRESSED_SIZE = 2 * 1024 * 1024; // 2MiB + private static final int VANILLA_MAXIMUM_UNCOMPRESSED_SIZE = 8 * 1024 * 1024; // 8MiB private static final int HARD_MAXIMUM_UNCOMPRESSED_SIZE = 16 * 1024 * 1024; // 16MiB private static final int UNCOMPRESSED_CAP = diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java index 28d005161..67ec9e1e2 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftCompressorAndLengthEncoder.java @@ -29,9 +29,6 @@ import java.util.zip.DataFormatException; public class MinecraftCompressorAndLengthEncoder extends MessageToByteEncoder { - private static final boolean MUST_USE_SAFE_AND_SLOW_COMPRESSION_HANDLING = - Boolean.getBoolean("velocity.increased-compression-cap"); - private int threshold; private final VelocityCompressor compressor; @@ -49,15 +46,11 @@ public class MinecraftCompressorAndLengthEncoder extends MessageToByteEncoder= 1 << 21) { - throw new DataFormatException("The server sent a very large (over 2MiB compressed) packet. " - + "Please restart Velocity with the JVM flag -Dvelocity.increased-compression-cap=true " - + "to fix this issue."); + throw new DataFormatException("The server sent a very large (over 2MiB compressed) packet."); } int writerIndex = out.writerIndex(); @@ -85,26 +76,6 @@ public class MinecraftCompressorAndLengthEncoder extends MessageToByteEncoder