mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-23 16:59:24 +00:00
fix linear region
This commit is contained in:
@@ -135,7 +135,7 @@ index c72494e757a9dc50e053dbc873f7b30e83d5cb8c..236035219dd2442592bb94994a44fab7
|
|||||||
}
|
}
|
||||||
// Paper end - rewrite chunk system
|
// Paper end - rewrite chunk system
|
||||||
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
index 6ebd1300c2561116b83cb2472ac7939ead36d576..60644b1a3c554b49ef72ff8fd27731352e9e3368 100644
|
index 6ebd1300c2561116b83cb2472ac7939ead36d576..6da756cb0a406a76151a5b2f624e08592f35d835 100644
|
||||||
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
--- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
+++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java
|
||||||
@@ -18,7 +18,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
@@ -18,7 +18,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||||
@@ -209,7 +209,7 @@ index 6ebd1300c2561116b83cb2472ac7939ead36d576..60644b1a3c554b49ef72ff8fd2773135
|
|||||||
|
|
||||||
this.regionCache.putAndMoveToFirst(key, ret);
|
this.regionCache.putAndMoveToFirst(key, ret);
|
||||||
|
|
||||||
@@ -144,7 +149,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
@@ -144,11 +149,11 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||||
}
|
}
|
||||||
|
|
||||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||||
@@ -218,6 +218,11 @@ index 6ebd1300c2561116b83cb2472ac7939ead36d576..60644b1a3c554b49ef72ff8fd2773135
|
|||||||
|
|
||||||
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
|
// note: not required to keep regionfile loaded after this call, as the write param takes a regionfile as input
|
||||||
// (and, the regionfile parameter is unused for writing until the write call)
|
// (and, the regionfile parameter is unused for writing until the write call)
|
||||||
|
- 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);
|
||||||
|
+ final ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData writeData = regionFile.moonrise$startWrite(compound, pos); // DivineMC - linear region format
|
||||||
|
|
||||||
|
try { // Paper - implement RegionFileSizeException
|
||||||
|
try {
|
||||||
@@ -178,7 +183,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
@@ -178,7 +183,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
final ChunkPos pos = new ChunkPos(chunkX, chunkZ);
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import java.io.DataOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.level.ChunkPos;
|
import net.minecraft.world.level.ChunkPos;
|
||||||
|
|
||||||
public interface AbstractRegionFile extends AutoCloseable {
|
public interface AbstractRegionFile extends AutoCloseable, ChunkSystemRegionFile {
|
||||||
Path getPath();
|
Path getPath();
|
||||||
void flush() throws IOException;
|
void flush() throws IOException;
|
||||||
void clear(ChunkPos pos) throws IOException;
|
void clear(ChunkPos pos) throws IOException;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package space.bxteam.divinemc.region;
|
package space.bxteam.divinemc.region;
|
||||||
|
|
||||||
|
import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO;
|
||||||
import com.github.luben.zstd.ZstdInputStream;
|
import com.github.luben.zstd.ZstdInputStream;
|
||||||
import com.github.luben.zstd.ZstdOutputStream;
|
import com.github.luben.zstd.ZstdOutputStream;
|
||||||
import com.mojang.logging.LogUtils;
|
import com.mojang.logging.LogUtils;
|
||||||
@@ -31,7 +32,7 @@ import net.minecraft.world.level.ChunkPos;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import space.bxteam.divinemc.configuration.DivineConfig;
|
import space.bxteam.divinemc.configuration.DivineConfig;
|
||||||
|
|
||||||
public class LinearRegionFile implements AbstractRegionFile, AutoCloseable {
|
public class LinearRegionFile implements AbstractRegionFile {
|
||||||
private static final long SUPERBLOCK = -4323716122432332390L;
|
private static final long SUPERBLOCK = -4323716122432332390L;
|
||||||
private static final byte VERSION = 2;
|
private static final byte VERSION = 2;
|
||||||
private static final int HEADER_SIZE = 32;
|
private static final int HEADER_SIZE = 32;
|
||||||
@@ -223,6 +224,16 @@ public class LinearRegionFile implements AbstractRegionFile, AutoCloseable {
|
|||||||
return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos)));
|
return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MoonriseRegionFileIO.RegionDataController.WriteData moonrise$startWrite(CompoundTag data, ChunkPos pos) throws IOException {
|
||||||
|
final DataOutputStream out = this.getChunkDataOutputStream(pos);
|
||||||
|
|
||||||
|
return new ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData(
|
||||||
|
data, ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.RegionDataController.WriteData.WriteResult.WRITE,
|
||||||
|
out, regionFile -> out.close()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private byte[] toByteArray(InputStream in) throws IOException {
|
private byte[] toByteArray(InputStream in) throws IOException {
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
byte[] tempBuffer = new byte[4096];
|
byte[] tempBuffer = new byte[4096];
|
||||||
|
|||||||
Reference in New Issue
Block a user