From e5b7dd2906f2f68c97b5adc9b77fb428c7c50fa2 Mon Sep 17 00:00:00 2001 From: Astralchroma Date: Sun, 23 Jul 2023 01:13:48 +0100 Subject: [PATCH] Configurable Region Compression Format (#8505) --- ...nfigurable-Region-Compression-Format.patch | 46 +++++++++++++++++++ patches/server/Paper-config-files.patch | 8 ++++ 2 files changed, 54 insertions(+) create mode 100644 patches/server/Configurable-Region-Compression-Format.patch diff --git a/patches/server/Configurable-Region-Compression-Format.patch b/patches/server/Configurable-Region-Compression-Format.patch new file mode 100644 index 0000000000..4157d2444d --- /dev/null +++ b/patches/server/Configurable-Region-Compression-Format.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Astralchroma +Date: Thu, 27 Oct 2022 22:19:31 +0100 +Subject: [PATCH] Configurable Region Compression Format + + +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java +@@ -0,0 +0,0 @@ public class RegionFile implements AutoCloseable { + // Paper end + + public RegionFile(Path file, Path directory, boolean dsync) throws IOException { +- this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync); ++ this(file, directory, RegionFileVersion.getCompressionFormat(), dsync); // Paper - Configurable region compression format + } + // Paper start - add can recalc flag + public RegionFile(Path file, Path directory, boolean dsync, boolean canRecalcHeader) throws IOException { +- this(file, directory, RegionFileVersion.VERSION_DEFLATE, dsync, canRecalcHeader); ++ this(file, directory, RegionFileVersion.getCompressionFormat(), dsync, canRecalcHeader); // Paper - Configurable region compression format + } + // Paper end - add can recalc flag + +diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java ++++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +@@ -0,0 +0,0 @@ public class RegionFileVersion { + }, (stream) -> { + return stream; + })); ++ ++ // 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 ++ + private final int id; + private final RegionFileVersion.StreamWrapper inputWrapper; + private final RegionFileVersion.StreamWrapper outputWrapper; diff --git a/patches/server/Paper-config-files.patch b/patches/server/Paper-config-files.patch index 84b6e5c31d..9149f622e7 100644 --- a/patches/server/Paper-config-files.patch +++ b/patches/server/Paper-config-files.patch @@ -589,6 +589,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean allowHeadlessPistons = false; + @Comment("This setting controls if grindstones should be able to output overstacked items (such as cursed books).") + public boolean allowGrindstoneOverstacking = false; ++ @Comment("This setting controls what compression format is used for region files.") ++ public CompressionFormat compressionFormat = CompressionFormat.ZLIB; ++ ++ public enum CompressionFormat { ++ GZIP, ++ ZLIB, ++ NONE ++ } + } + + public Commands commands;