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
--- 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);

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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;
}

View file

@ -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 {
}
}

View file

@ -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 {

View file

@ -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<ByteBuf> {
@@ -0,0 +0,0 @@ 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 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 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<ByteBuf> {
}
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