9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-23 17:09:26 +00:00

Update Paper (#261)

This commit is contained in:
Bluemangoo
2024-07-19 20:38:04 +08:00
committed by GitHub
parent a872cd0de5
commit 3992c7945f
38 changed files with 436 additions and 464 deletions

View File

@@ -36,10 +36,10 @@ index 73df26b27146bbad2106d57b22dd3c792ed3dd1d..f3bd1488da34ea796c8205088e83d4c5
}
diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
index c833f78d083b8f661087471c35bc90f65af1b525..8a00fd8c05df53ac99f214254e4dd9bd71858162 100644
index 3218cbf84f54daf06e84442d5eb1a36d8da6b215..80dd90189d7790066b2e42285f256f21b146600c 100644
--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
+++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/io/RegionFileIOThread.java
@@ -1042,9 +1042,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
@@ -1043,9 +1043,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
return ((ChunkSystemRegionFileStorage)(Object)this.getCache()).moonrise$doesRegionFileNotExistNoIO(chunkX, chunkZ);
}
@@ -51,7 +51,7 @@ index c833f78d083b8f661087471c35bc90f65af1b525..8a00fd8c05df53ac99f214254e4dd9bd
synchronized (cache) {
try {
if (existingOnly) {
@@ -1060,9 +1060,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
@@ -1061,9 +1061,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread {
}
}
@@ -113,7 +113,7 @@ index cb39c629af1827078f35904a373d35a63fea17ff..4f8ec87adc72f096caeb4bb437c5f43b
}
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 e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..2fefc69cc1df01a5ede2e5f2642adec6238e6368 100644
index eb0389ad86300665b6e057bcfa1d7c068dc6c6ab..22cfab0214c75bab89c4aeeb98fdc81340b0fe4a 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
@@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtIo; // Paper
@@ -125,7 +125,16 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..2fefc69cc1df01a5ede2e5f2642adec6
private static final Logger LOGGER = LogUtils.getLogger();
private static final int SECTOR_BYTES = 4096;
@@ -465,10 +465,10 @@ public class RegionFile implements AutoCloseable {
@@ -129,7 +129,7 @@ public class RegionFile implements AutoCloseable {
}
// note: only call for CHUNK regionfiles
- boolean recalculateHeader() throws IOException {
+ public boolean recalculateHeader() throws IOException { // Leaves - make it public
if (!this.canRecalcHeader) {
return false;
}
@@ -928,10 +928,10 @@ public class RegionFile implements AutoCloseable {
private static int getChunkIndex(int x, int z) {
return (x & 31) + (z & 31) * 32;
}
@@ -138,7 +147,7 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..2fefc69cc1df01a5ede2e5f2642adec6
final int offset = getChunkIndex(x, z);
boolean previous = this.oversized[offset] == 1;
this.oversized[offset] = (byte) (oversized ? 1 : 0);
@@ -507,7 +507,7 @@ public class RegionFile implements AutoCloseable {
@@ -970,7 +970,7 @@ public class RegionFile implements AutoCloseable {
return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt");
}
@@ -148,7 +157,7 @@ index e761b63eebc1e76b2bb1cb887d83d0b63ad6ec90..2fefc69cc1df01a5ede2e5f2642adec6
try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) {
return NbtIo.read((java.io.DataInput) out);
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
index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d82e59b32 100644
index 40689256711cc94a806ca1da346f4f62eda31526..b5ab653c0e3963f2b925acd1e0287cd91ab88661 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
@@ -21,7 +21,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -225,8 +234,8 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
this.regionCache.putAndMoveToFirst(key, ret);
@@ -112,7 +122,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.info = storageKey;
@@ -143,7 +153,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
this.isChunkData = isChunkDataFolder(this.folder); // Paper - recalculate region file headers
}
- public RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // Paper - public
@@ -234,7 +243,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
// Paper start - rewrite chunk system
if (existingOnly) {
return this.moonrise$getRegionFileIfExists(chunkcoordintpair.x, chunkcoordintpair.z);
@@ -120,7 +130,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -151,7 +161,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
synchronized (this) {
final long key = ChunkPos.asLong(chunkcoordintpair.x >> REGION_SHIFT, chunkcoordintpair.z >> REGION_SHIFT);
@@ -243,7 +252,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
if (ret != null) {
return ret;
}
@@ -135,7 +145,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -166,7 +176,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
FileUtil.createDirectoriesSafe(this.folder);
@@ -252,7 +261,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
this.regionCache.putAndMoveToFirst(key, ret);
@@ -149,7 +159,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -180,7 +190,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed.");
}
@@ -261,7 +270,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
synchronized (regionfile) {
try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) {
CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z);
@@ -184,7 +194,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -215,7 +225,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@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
@@ -270,7 +279,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
if (regionfile == null) {
return null;
}
@@ -235,7 +245,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -279,7 +289,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException {
// CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing
@@ -279,7 +288,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
if (regionfile == null) {
return;
}
@@ -265,7 +275,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -309,7 +319,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
}
public void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { // Paper - public
@@ -288,7 +297,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
// Paper start - rewrite chunk system
if (regionfile == null) {
// if the RegionFile doesn't exist, no point in deleting from it
@@ -281,8 +291,33 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -325,8 +335,33 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
if (nbt == null) {
regionfile.clear(pos);
} else {
@@ -323,7 +332,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
try {
NbtIo.write(nbt, (DataOutput) dataoutputstream);
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
@@ -324,7 +359,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -368,7 +403,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -332,7 +341,7 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
try {
regionFile.close();
} catch (final IOException ex) {
@@ -341,7 +376,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
@@ -385,7 +420,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise
// Paper start - rewrite chunk system
synchronized (this) {
final ExceptionCollector<IOException> exceptionCollector = new ExceptionCollector<>();
@@ -343,10 +352,10 @@ index 0615fd82b71efb9a397de01615050e6d906c2844..f400a188b70ea74f986f05861c35671d
} catch (final IOException ex) {
diff --git a/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..e5439ece2a33a8d88df6423eca22a895129fdbf4
index 0000000000000000000000000000000000000000..1b9da27d9f409684917680e41a1aae583f021c20
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/region/AbstractRegionFile.java
@@ -0,0 +1,37 @@
@@ -0,0 +1,39 @@
+package org.leavesmc.leaves.region;
+
+import net.minecraft.nbt.CompoundTag;
@@ -369,6 +378,8 @@ index 0000000000000000000000000000000000000000..e5439ece2a33a8d88df6423eca22a895
+
+ CompoundTag getOversizedData(int x, int z) throws IOException;
+
+ boolean recalculateHeader() throws IOException ;
+
+ boolean hasChunk(ChunkPos pos);
+
+ boolean doesChunkExist(ChunkPos pos);
@@ -416,10 +427,10 @@ index 0000000000000000000000000000000000000000..72f4507aa10f2ecad545199ccb88038f
+}
diff --git a/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java b/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..0c0ccc4d1848ee3c440fbe4b924aead09c9947dc
index 0000000000000000000000000000000000000000..381897d87b10147a67dbb13194eb054d4823c9de
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/region/LinearRegionFile.java
@@ -0,0 +1,314 @@
@@ -0,0 +1,319 @@
+package org.leavesmc.leaves.region;
+
+import com.github.luben.zstd.ZstdInputStream;
@@ -716,6 +727,11 @@ index 0000000000000000000000000000000000000000..0c0ccc4d1848ee3c440fbe4b924aead0
+ throw new IOException("getOversizedData is a stub " + this.path);
+ }
+
+ @Override
+ public boolean recalculateHeader() {
+ return false;
+ }
+
+ public boolean isOversized(int x, int z) {
+ return false;
+ }