Handle bad chunks more gracefully

Prior to this change the server would crash when attempting to load a
chunk from a region with bad data.

After this change the server will defer back to vanilla behavior. At
this time, that means attempting to generate a chunk in its place
(and occasionally just not generating anything and leaving small
holes in the world).

Should Mojang choose to alter this behavior in the future, this change
will simply defer to whatever that new behavior is.
This commit is contained in:
Zach Brown 2018-04-17 22:00:51 -04:00
parent 0abd56b79e
commit 53c4a446eb

View file

@ -0,0 +1,51 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Zach Brown <1254957+zachbr@users.noreply.github.com>
Date: Tue, 17 Apr 2018 21:26:31 -0400
Subject: [PATCH] Handle bad chunks more gracefully
Prior to this change the server would crash when attempting to load a
chunk from a region with bad data.
After this change the server will defer back to vanilla behavior. At
this time, that means attempting to generate a chunk in its place
(and occasionally just not generating anything and leaving small
holes in the world).
Should Mojang choose to alter this behavior in the future, this change
will simply defer to whatever that new behavior is.
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 1e84afb0a..9055da64a 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider {
chunk = originalGetChunkAt(i, j);
}
+ // Paper start - If there was an issue loading the chunk from region, stage1 will fail and stage2 will load it sync
+ // all we need to do is fetch an instance
+ if (chunk == null) {
+ chunk = getChunkIfLoaded(i, j);
+ }
+ // Paper end
+
// If we didn't load the chunk async and have a callback run it now
if (runnable != null) {
runnable.run();
diff --git a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
index ef9529add..cdf3b614c 100644
--- a/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
+++ b/src/main/java/org/bukkit/craftbukkit/chunkio/ChunkIOProvider.java
@@ -0,0 +0,0 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
return null;
} catch (IOException ex) {
throw new RuntimeException(ex);
+ // Paper - Mirror vanilla by catching everything (else) rather than immediately crashing the server
+ // stage2 will receive a null chunk and then load it synchronously, where vanilla MC will properly log and recover
+ // stage2 will _not_ however return that instance, only load it
+ } catch (Exception ex) {
+ return null;
}
}
--