Rebuild patches

This commit is contained in:
Jason Penilla 2023-09-22 10:59:56 -07:00
parent 845d5e7a06
commit 05f9968013
7 changed files with 43 additions and 102 deletions

View file

@ -145,7 +145,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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 @Nullable
public CompoundTag read(ChunkPos pos) throws IOException { 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 // 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 // CraftBukkit end
DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos); DataInputStream datainputstream = regionfile.getChunkDataInputStream(pos);
@ -230,7 +230,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CompoundTag nbttagcompound; CompoundTag nbttagcompound;
label43: label43:
{ {
@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
try { try {
NbtIo.write(nbt, (DataOutput) dataoutputstream); NbtIo.write(nbt, (DataOutput) dataoutputstream);

View file

@ -22,7 +22,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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 { protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException {
RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit RegionFile regionfile = this.getRegionFile(pos, false); // CraftBukkit
@ -30,7 +30,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (nbt == null) { if (nbt == null) {
regionfile.clear(pos); regionfile.clear(pos);
@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
dataoutputstream.close(); dataoutputstream.close();
} }
} }

View file

@ -145,7 +145,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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 { try {
NbtIo.write(nbt, (DataOutput) dataoutputstream); NbtIo.write(nbt, (DataOutput) dataoutputstream);

View file

@ -329,7 +329,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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; this.sync = dsync;
} }

View file

@ -50,7 +50,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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); NbtIo.write(nbt, (DataOutput) dataoutputstream);
regionfile.setStatus(pos.x, pos.z, ChunkSerializer.getStatus(nbt)); // Paper - cache status on disk 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 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) { } catch (Throwable throwable1) {
throwable.addSuppressed(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; throw throwable;
} }
@ -81,7 +81,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
// Paper start // Paper start
return; return;
@@ -0,0 +0,0 @@ public final class RegionFileStorage implements AutoCloseable { @@ -0,0 +0,0 @@ public class RegionFileStorage implements AutoCloseable {
} }
} }

View file

@ -14,7 +14,7 @@ diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileSto
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java --- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
+++ b/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) { if (regionfile != null) {
return regionfile; return regionfile;
} else { } else {

View file

@ -174,73 +174,23 @@ diff --git a/src/main/java/net/minecraft/network/CompressionEncoder.java b/src/m
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/CompressionEncoder.java --- a/src/main/java/net/minecraft/network/CompressionEncoder.java
+++ b/src/main/java/net/minecraft/network/CompressionEncoder.java +++ b/src/main/java/net/minecraft/network/CompressionEncoder.java
@@ -0,0 +0,0 @@ @@ -0,0 +0,0 @@ import io.netty.handler.codec.MessageToByteEncoder;
-package net.minecraft.network; import java.util.zip.Deflater;
-
-import io.netty.buffer.ByteBuf; public class CompressionEncoder extends MessageToByteEncoder<ByteBuf> {
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.MessageToByteEncoder;
-import java.util.zip.Deflater;
-
-public class CompressionEncoder extends MessageToByteEncoder<ByteBuf> {
- private final byte[] encodeBuf = new byte[8192]; - 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<ByteBuf> {
+ private final byte[] encodeBuf; // Paper + private final byte[] encodeBuf; // Paper
+ private final Deflater deflater; private final Deflater deflater;
+ private final com.velocitypowered.natives.compression.VelocityCompressor compressor; // Paper + private final com.velocitypowered.natives.compression.VelocityCompressor compressor; // Paper
+ private int threshold; private int threshold;
+
+ // Paper start + // Paper start
+ public CompressionEncoder(int compressionThreshold) { public CompressionEncoder(int compressionThreshold) {
+ this(null, compressionThreshold); + this(null, compressionThreshold);
+ } + }
+ public CompressionEncoder(com.velocitypowered.natives.compression.VelocityCompressor compressor, int compressionThreshold) { + public CompressionEncoder(com.velocitypowered.natives.compression.VelocityCompressor compressor, int compressionThreshold) {
+ this.threshold = compressionThreshold; this.threshold = compressionThreshold;
- this.deflater = new Deflater();
+ if (compressor == null) { + if (compressor == null) {
+ this.encodeBuf = new byte[8192]; + this.encodeBuf = new byte[8192];
+ this.deflater = new Deflater(); + this.deflater = new Deflater();
@ -250,28 +200,24 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ this.compressor = compressor; + this.compressor = compressor;
+ // Paper end + // Paper end
+ } }
+
- protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) {
+ protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) throws Exception { // Paper + protected void encode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, ByteBuf byteBuf2) throws Exception { // Paper
+ int i = byteBuf.readableBytes(); int i = byteBuf.readableBytes();
+ if (i < this.threshold) { if (i < this.threshold) {
+ VarInt.write(byteBuf2, 0); VarInt.write(byteBuf2, 0);
+ byteBuf2.writeBytes(byteBuf); byteBuf2.writeBytes(byteBuf);
+ } else { } else {
+ // Paper start + // Paper start
+ if (this.deflater != null) { + if (this.deflater != null) {
+ byte[] bs = new byte[i]; byte[] bs = new byte[i];
+ byteBuf.readBytes(bs); byteBuf.readBytes(bs);
+ VarInt.write(byteBuf2, bs.length); VarInt.write(byteBuf2, bs.length);
+ this.deflater.setInput(bs, 0, i); @@ -0,0 +0,0 @@ public class CompressionEncoder extends MessageToByteEncoder<ByteBuf> {
+ this.deflater.finish(); }
+
+ while(!this.deflater.finished()) { this.deflater.reset();
+ int j = this.deflater.deflate(this.encodeBuf);
+ byteBuf2.writeBytes(this.encodeBuf, 0, j);
+ }
+
+ this.deflater.reset();
+ return; + return;
+ } + }
+ +
@ -283,10 +229,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ compatibleIn.release(); + compatibleIn.release();
+ } + }
+ // Paper end + // Paper end
+ } }
+
+ } }
+
+ // Paper start + // Paper start
+ @Override + @Override
+ protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception{ + protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect) throws Exception{
@ -314,14 +260,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ } + }
+ // Paper end + // Paper end
+ +
+ public int getThreshold() { public int getThreshold() {
+ return this.threshold; return this.threshold;
+ } }
+
+ public void setThreshold(int compressionThreshold) {
+ this.threshold = compressionThreshold;
+ }
+}
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java