Paper/nms-patches/RegionFileCache.patch

51 lines
1.9 KiB
Diff
Raw Normal View History

--- a/net/minecraft/server/RegionFileCache.java
+++ b/net/minecraft/server/RegionFileCache.java
2019-04-23 04:00:00 +02:00
@@ -18,7 +18,7 @@
this.a = file;
2018-08-26 04:00:00 +02:00
}
2019-04-23 04:00:00 +02:00
- private RegionFile a(ChunkCoordIntPair chunkcoordintpair) throws IOException {
+ private RegionFile a(ChunkCoordIntPair chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit
long i = ChunkCoordIntPair.pair(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ());
RegionFile regionfile = (RegionFile) this.cache.getAndMoveToFirst(i);
2018-08-26 04:00:00 +02:00
2019-04-23 04:00:00 +02:00
@@ -34,6 +34,7 @@
}
File file = new File(this.a, "r." + chunkcoordintpair.getRegionX() + "." + chunkcoordintpair.getRegionZ() + ".mca");
+ if (existingOnly && !file.exists()) return null; // CraftBukkit
RegionFile regionfile1 = new RegionFile(file);
this.cache.putAndMoveToFirst(i, regionfile1);
@@ -43,7 +44,7 @@
2018-07-15 02:00:00 +02:00
@Nullable
2019-04-23 04:00:00 +02:00
public NBTTagCompound read(ChunkCoordIntPair chunkcoordintpair) throws IOException {
- RegionFile regionfile = this.a(chunkcoordintpair);
+ RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit
DataInputStream datainputstream = regionfile.a(chunkcoordintpair);
Throwable throwable = null;
2019-04-23 04:00:00 +02:00
@@ -78,7 +79,7 @@
}
2019-04-23 04:00:00 +02:00
protected void write(ChunkCoordIntPair chunkcoordintpair, NBTTagCompound nbttagcompound) throws IOException {
- RegionFile regionfile = this.a(chunkcoordintpair);
+ RegionFile regionfile = this.a(chunkcoordintpair, false); // CraftBukkit
DataOutputStream dataoutputstream = regionfile.c(chunkcoordintpair);
Throwable throwable = null;
2019-04-23 04:00:00 +02:00
@@ -114,4 +115,12 @@
}
}
2018-08-26 04:00:00 +02:00
+
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
+ public boolean chunkExists(ChunkCoordIntPair pos) throws IOException {
+ RegionFile regionfile = a(pos, true);
2018-08-26 04:00:00 +02:00
+
2019-04-23 04:00:00 +02:00
+ return regionfile != null ? regionfile.d(pos) : false;
+ }
+ // CraftBukkit end
2018-08-26 04:00:00 +02:00
}