Skip to content

Commit 22bd0e7

Browse files
committed
Backport Linear fix
1 parent 80691cb commit 22bd0e7

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

patches/server/0045-Linear-region-file-format.patch

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ index b26a5b76cd30c96ce15ced5ac51222a8333bde52..dd42303de58274c24394da26bda52bf0
196196
}
197197
// Paper end - rewrite chunk system
198198
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
199-
index 79aca7e7cd2f860464657e77e935391642981fad..6721adad3d227acba8daba80b0b7e1df3bc0b046 100644
199+
index 79aca7e7cd2f860464657e77e935391642981fad..1ae102bcf2dfd72ec36703aecd8f0deff132bcca 100644
200200
--- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
201201
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
202202
@@ -23,7 +23,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -248,7 +248,7 @@ index 79aca7e7cd2f860464657e77e935391642981fad..6721adad3d227acba8daba80b0b7e1df
248248

249249
this.regionCache.putAndMoveToFirst(key, ret);
250250

251-
@@ -119,7 +123,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
251+
@@ -119,11 +123,11 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
252252
}
253253

254254
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -257,6 +257,11 @@ index 79aca7e7cd2f860464657e77e935391642981fad..6721adad3d227acba8daba80b0b7e1df
257257

258258
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
259259
// (and, the regionfile parameter is unused for writing until the write call)
260+
- final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData writeData = ((ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile)regionFile).moonrise$startWrite(compound, pos);
261+
+ final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData writeData = regionFile.moonrise$startWrite(compound, pos); // LinearPaper
262+
263+
try { // Paper - implement RegionFileSizeException
264+
try {
260265
@@ -153,7 +157,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
261266
) throws IOException {
262267
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
@@ -510,10 +515,10 @@ index 0000000000000000000000000000000000000000..8eba172be9bce7cccd27d27bee2d6c6f
510515
+}
511516
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
512517
new file mode 100644
513-
index 0000000000000000000000000000000000000000..77a3629aeae5dfde37b8ea3da97ed008a30e1b94
518+
index 0000000000000000000000000000000000000000..6a9b8178cca07335fbe8244fd1859b241ae35034
514519
--- /dev/null
515520
+++ b/src/main/java/org/stupidcraft/linearpaper/region/IRegionFile.java
516-
@@ -0,0 +1,28 @@
521+
@@ -0,0 +1,29 @@
517522
+package org.stupidcraft.linearpaper.region;
518523
+
519524
+import java.io.DataInputStream;
@@ -522,10 +527,11 @@ index 0000000000000000000000000000000000000000..77a3629aeae5dfde37b8ea3da97ed008
522527
+import java.nio.ByteBuffer;
523528
+import java.nio.file.Path;
524529
+
530+
+import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile;
525531
+import net.minecraft.nbt.CompoundTag;
526532
+import net.minecraft.world.level.ChunkPos;
527533
+
528-
+public interface IRegionFile {
534+
+public interface IRegionFile extends AutoCloseable, ChunkSystemRegionFile {
529535
+ Path getPath();
530536
+ void flush() throws IOException;
531537
+ void clear(ChunkPos pos) throws IOException;
@@ -602,12 +608,13 @@ index 0000000000000000000000000000000000000000..70552d63a84a4d3a73348d0dffacd89c
602608
+}
603609
diff --git a/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
604610
new file mode 100644
605-
index 0000000000000000000000000000000000000000..d2cbdd75f02d377a7680288bb1154d51dbc6bc51
611+
index 0000000000000000000000000000000000000000..ea4b9227da76143a6b1aef7924ab634899c81120
606612
--- /dev/null
607613
+++ b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java
608-
@@ -0,0 +1,299 @@
614+
@@ -0,0 +1,309 @@
609615
+package org.stupidcraft.linearpaper.region;
610616
+
617+
+import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO;
611618
+import com.github.luben.zstd.ZstdInputStream;
612619
+import com.github.luben.zstd.ZstdOutputStream;
613620
+import com.mojang.logging.LogUtils;
@@ -832,6 +839,15 @@ index 0000000000000000000000000000000000000000..d2cbdd75f02d377a7680288bb1154d51
832839
+ return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos)));
833840
+ }
834841
+
842+
+ @Override
843+
+ public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(CompoundTag data, ChunkPos pos) throws IOException {
844+
+ final DataOutputStream out = this.getChunkDataOutputStream(pos);
845+
+ return new ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData(
846+
+ data, ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.WRITE,
847+
+ out, regionFile -> out.close()
848+
+ );
849+
+ }
850+
+
835851
+ private byte[] toByteArray(InputStream in) throws IOException {
836852
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
837853
+ byte[] tempBuffer = new byte[4096];

0 commit comments

Comments
 (0)