SPIGOT-2322: Chunks generating with missing / corrupted data.

This commit is contained in:
md_5 2016-06-12 12:28:08 +10:00
parent f642d4bcc3
commit 1f507256e7

View File

@ -13,11 +13,10 @@
public class ChunkProviderServer implements IChunkProvider { public class ChunkProviderServer implements IChunkProvider {
private static final Logger a = LogManager.getLogger(); private static final Logger a = LogManager.getLogger();
@@ -69,19 +75,74 @@ @@ -69,6 +75,26 @@
Chunk chunk = this.getLoadedChunkAt(i, j); Chunk chunk = this.getLoadedChunkAt(i, j);
if (chunk == null) { if (chunk == null) {
- chunk = this.loadChunk(i, j);
+ // CraftBukkit start + // CraftBukkit start
+ ChunkRegionLoader loader = null; + ChunkRegionLoader loader = null;
+ +
@ -27,16 +26,21 @@
+ if (loader != null && loader.chunkExists(world, i, j)) { + if (loader != null && loader.chunkExists(world, i, j)) {
+ chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j); + chunk = ChunkIOExecutor.syncChunkLoad(world, loader, this, i, j);
+ } + }
+ /* chunk = this.loadChunk(i, j); + }
+
+ return chunk;
+ }
+
+ @Nullable
+ public Chunk originalGetOrLoadChunkAt(int i, int j) {
+ // CraftBukkit end
+ Chunk chunk = this.getLoadedChunkAt(i, j);
+
+ if (chunk == null) {
chunk = this.loadChunk(i, j);
if (chunk != null) { if (chunk != null) {
this.chunks.put(ChunkCoordIntPair.a(i, j), chunk); this.chunks.put(ChunkCoordIntPair.a(i, j), chunk);
chunk.addEntities(); @@ -80,8 +106,52 @@
chunk.loadNearby(this, this.chunkGenerator);
}
+ */
+ // CraftBukkit end
}
return chunk; return chunk;
} }
@ -84,13 +88,13 @@
+ } + }
+ +
+ public Chunk originalGetChunkAt(int i, int j) { + public Chunk originalGetChunkAt(int i, int j) {
+ Chunk chunk = this.getLoadedChunkAt(i, j); + Chunk chunk = this.originalGetOrLoadChunkAt(i, j);
+ boolean newChunk = false; + boolean newChunk = false;
+ // CraftBukkit end + // CraftBukkit end
if (chunk == null) { if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j); long k = ChunkCoordIntPair.a(i, j);
@@ -97,9 +158,37 @@ @@ -97,9 +167,37 @@
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator); crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
@ -128,7 +132,7 @@
chunk.loadNearby(this, this.chunkGenerator); chunk.loadNearby(this, this.chunkGenerator);
} }
@@ -146,10 +235,12 @@ @@ -146,10 +244,12 @@
public boolean a(boolean flag) { public boolean a(boolean flag) {
int i = 0; int i = 0;
@ -144,7 +148,7 @@
if (flag) { if (flag) {
this.saveChunkNOP(chunk); this.saveChunkNOP(chunk);
@@ -182,6 +273,29 @@ @@ -182,6 +282,29 @@
Chunk chunk = (Chunk) this.chunks.get(olong); Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) { if (chunk != null && chunk.d) {