Configurable Region Compression Format

This commit is contained in:
Astralchroma 2022-10-27 22:19:31 +01:00
parent 53fab9663b
commit 1abc111403
2 changed files with 27 additions and 0 deletions

View file

@ -5,6 +5,15 @@
package net.minecraft.world.level.chunk.storage;
import com.google.common.annotations.VisibleForTesting;
@@ -49,7 +50,7 @@
protected final RegionBitmap usedSectors;
public RegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException {
- this(storageKey, directory, path, RegionFileVersion.getSelected(), dsync);
+ this(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format
}
public RegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync) throws IOException {
@@ -63,8 +64,8 @@
} else {
this.externalFileDir = directory;

View file

@ -0,0 +1,18 @@
--- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java
+++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java
@@ -58,6 +58,15 @@
private final RegionFileVersion.StreamWrapper<InputStream> inputWrapper;
private final RegionFileVersion.StreamWrapper<OutputStream> outputWrapper;
+ // Paper start - Configurable region compression format
+ public static RegionFileVersion getCompressionFormat() {
+ return switch (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.compressionFormat) {
+ case GZIP -> VERSION_GZIP;
+ case ZLIB -> VERSION_DEFLATE;
+ case NONE -> VERSION_NONE;
+ };
+ }
+ // Paper end - Configurable region compression format
private RegionFileVersion(
int id,
@Nullable String name,