From 05f99680135b4d45839467d479a95874dfd77284 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Fri, 22 Sep 2023 10:59:56 -0700 Subject: [PATCH] Rebuild patches --- .../Allow-Saving-of-Oversized-Chunks.patch | 6 +- patches/server/Chunk-Save-Reattempt.patch | 4 +- .../Fix-World-isChunkGenerated-calls.patch | 2 +- ...x-and-optimise-world-force-upgrading.patch | 2 +- ...-data-to-disk-if-it-serializes-witho.patch | 6 +- ...egionFileCache-and-make-configurable.patch | 2 +- ...ocity-compression-and-cipher-natives.patch | 123 +++++------------- 7 files changed, 43 insertions(+), 102 deletions(-) diff --git a/patches/server/Allow-Saving-of-Oversized-Chunks.patch b/patches/server/Allow-Saving-of-Oversized-Chunks.patch index 02bfb6688e..55354892a5 100644 --- a/patches/server/Allow-Saving-of-Oversized-Chunks.patch +++ b/patches/server/Allow-Saving-of-Oversized-Chunks.patch @@ -145,7 +145,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { } } @@ -217,7 +217,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Nullable public CompoundTag read(ChunkPos pos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { // CraftBukkit end DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); @@ -230,7 +230,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 CompoundTag nbttagcompound; label43: { -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { try { NbtIo.write(nbt, (DataOutput) dataoutputstream); diff --git a/patches/server/Chunk-Save-Reattempt.patch b/patches/server/Chunk-Save-Reattempt.patch index 854dcf977a..ec5a4e51e9 100644 --- a/patches/server/Chunk-Save-Reattempt.patch +++ b/patches/server/Chunk-Save-Reattempt.patch @@ -22,7 +22,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit @@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 if (nbt == null) { regionfile.clear(pos); -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { dataoutputstream.close(); } } diff --git a/patches/server/Fix-World-isChunkGenerated-calls.patch b/patches/server/Fix-World-isChunkGenerated-calls.patch index aa3f269a75..b72a9bad68 100644 --- a/patches/server/Fix-World-isChunkGenerated-calls.patch +++ b/patches/server/Fix-World-isChunkGenerated-calls.patch @@ -145,7 +145,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { try { NbtIo.write(nbt, (DataOutput) dataoutputstream); diff --git a/patches/server/Fix-and-optimise-world-force-upgrading.patch b/patches/server/Fix-and-optimise-world-force-upgrading.patch index 64fcd4f99b..92b72f5794 100644 --- a/patches/server/Fix-and-optimise-world-force-upgrading.patch +++ b/patches/server/Fix-and-optimise-world-force-upgrading.patch @@ -329,7 +329,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { this.sync = dsync; } diff --git a/patches/server/Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/patches/server/Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index 33d526b87c..c1082a5a44 100644 --- a/patches/server/Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/patches/server/Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -50,7 +50,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { NbtIo.write(nbt, (DataOutput) dataoutputstream); regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk regionfile.setOversized(pos.x, pos.z, false); // Paper - We don't do this anymore, mojang stores differently, but clear old meta flag if it exists to get rid of our own meta file once last oversized is gone @@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } catch (Throwable throwable1) { throwable.addSuppressed(throwable1); } -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { throw throwable; } @@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } // Paper start return; -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { } } diff --git a/patches/server/Sanitise-RegionFileCache-and-make-configurable.patch b/patches/server/Sanitise-RegionFileCache-and-make-configurable.patch index 09ce5ea938..6dc02058ac 100644 --- a/patches/server/Sanitise-RegionFileCache-and-make-configurable.patch +++ b/patches/server/Sanitise-RegionFileCache-and-make-configurable.patch @@ -14,7 +14,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { +@@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable { if (regionfile != null) { return regionfile; } else { diff --git a/patches/server/Use-Velocity-compression-and-cipher-natives.patch b/patches/server/Use-Velocity-compression-and-cipher-natives.patch index eb8fa2715a..d9700d0d77 100644 --- a/patches/server/Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/Use-Velocity-compression-and-cipher-natives.patch @@ -174,73 +174,23 @@ diff --git a/src/main/java/net/minecraft/network/CompressionEncoder.java b/src/m index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/CompressionEncoder.java +++ b/src/main/java/net/minecraft/network/CompressionEncoder.java -@@ -0,0 +0,0 @@ --package net.minecraft.network; -- --import io.netty.buffer.ByteBuf; --import io.netty.channel.ChannelHandlerContext; --import io.netty.handler.codec.MessageToByteEncoder; --import java.util.zip.Deflater; -- --public class CompressionEncoder extends MessageToByteEncoder { +@@ -0,0 +0,0 @@ import io.netty.handler.codec.MessageToByteEncoder; + import java.util.zip.Deflater; + + public class CompressionEncoder extends MessageToByteEncoder { - private final byte[] encodeBuf = new byte[8192]; -- private final Deflater deflater; -- private int threshold; -- -- public CompressionEncoder(int compressionThreshold) { -- this.threshold = compressionThreshold; -- this.deflater = new Deflater(); -- } -- -- protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) { -- int i = byteBuf.readableBytes(); -- if (i < this.threshold) { -- VarInt.write(byteBuf2, 0); -- byteBuf2.writeBytes(byteBuf); -- } else { -- byte[] bs = new byte[i]; -- byteBuf.readBytes(bs); -- VarInt.write(byteBuf2, bs.length); -- this.deflater.setInput(bs, 0, i); -- this.deflater.finish(); -- -- while(!this.deflater.finished()) { -- int j = this.deflater.deflate(this.encodeBuf); -- byteBuf2.writeBytes(this.encodeBuf, 0, j); -- } -- -- this.deflater.reset(); -- } -- -- } -- -- public int getThreshold() { -- return this.threshold; -- } -- -- public void setThreshold(int compressionThreshold) { -- this.threshold = compressionThreshold; -- } --} -+package net.minecraft.network; -+ -+import io.netty.buffer.ByteBuf; -+import io.netty.channel.ChannelHandlerContext; -+import io.netty.handler.codec.MessageToByteEncoder; -+import java.util.zip.Deflater; -+ -+public class CompressionEncoder extends MessageToByteEncoder { + private final byte[] encodeBuf; // Paper -+ private final Deflater deflater; + private final Deflater deflater; + private final com.velocitypowered.natives.compression.VelocityCompressor compressor; // Paper -+ private int threshold; -+ + private int threshold; + + // Paper start -+ public CompressionEncoder(int compressionThreshold) { + public CompressionEncoder(int compressionThreshold) { + this(null, compressionThreshold); + } + public CompressionEncoder(com.velocitypowered.natives.compression.VelocityCompressor compressor, int compressionThreshold) { -+ this.threshold = compressionThreshold; + this.threshold = compressionThreshold; +- this.deflater = new Deflater(); + if (compressor == null) { + this.encodeBuf = new byte[8192]; + this.deflater = new Deflater(); @@ -250,28 +200,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + this.compressor = compressor; + // Paper end -+ } -+ + } + +- protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) { + protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) throws Exception { // Paper -+ int i = byteBuf.readableBytes(); -+ if (i < this.threshold) { -+ VarInt.write(byteBuf2, 0); -+ byteBuf2.writeBytes(byteBuf); -+ } else { + int i = byteBuf.readableBytes(); + if (i < this.threshold) { + VarInt.write(byteBuf2, 0); + byteBuf2.writeBytes(byteBuf); + } else { + // Paper start + if (this.deflater != null) { -+ byte[] bs = new byte[i]; -+ byteBuf.readBytes(bs); -+ VarInt.write(byteBuf2, bs.length); -+ this.deflater.setInput(bs, 0, i); -+ this.deflater.finish(); -+ -+ while(!this.deflater.finished()) { -+ int j = this.deflater.deflate(this.encodeBuf); -+ byteBuf2.writeBytes(this.encodeBuf, 0, j); -+ } -+ -+ this.deflater.reset(); + byte[] bs = new byte[i]; + byteBuf.readBytes(bs); + VarInt.write(byteBuf2, bs.length); +@@ -0,0 +0,0 @@ public class CompressionEncoder extends MessageToByteEncoder { + } + + this.deflater.reset(); + return; + } + @@ -283,10 +229,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + compatibleIn.release(); + } + // Paper end -+ } -+ -+ } -+ + } + + } + + // Paper start + @Override + protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception{ @@ -314,14 +260,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + // Paper end + -+ public int getThreshold() { -+ return this.threshold; -+ } -+ -+ public void setThreshold(int compressionThreshold) { -+ this.threshold = compressionThreshold; -+ } -+} + public int getThreshold() { + return this.threshold; + } diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/network/Connection.java