Skip to content

Instantly share code, notes, and snippets.

@md-5

md-5/- Secret

Created March 5, 2016 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save md-5/13c4c0bd55fb00ee6eb1 to your computer and use it in GitHub Desktop.
Save md-5/13c4c0bd55fb00ee6eb1 to your computer and use it in GitHub Desktop.
diff --git a/nms-patches/ChunkProviderServer.patch b/nms-patches/ChunkProviderServer.patch
index cb45aa3..59932d5 100644
--- a/nms-patches/ChunkProviderServer.patch
+++ b/nms-patches/ChunkProviderServer.patch
@@ -79,11 +79,16 @@
while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next();
-@@ -49,11 +70,15 @@
+@@ -49,11 +70,20 @@
}
+ // CraftBukkit start - Add async variant, provide compatibility
++ public Chunk getOrCreateChunkFast(int x, int z) {
++ Chunk chunk = chunks.get(LongHash.toLong(x, z));
++ return (chunk == null) ? getChunkAt(x, z) : chunk;
++ }
++
+ public Chunk getChunkIfLoaded(int x, int z) {
+ return chunks.get(LongHash.toLong(x, z));
+ }
@@ -98,7 +103,7 @@
return chunk;
}
-@@ -61,20 +86,67 @@
+@@ -61,20 +91,67 @@
Chunk chunk = this.getLoadedChunkAt(i, j);
if (chunk == null) {
@@ -168,7 +173,7 @@
if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j);
-@@ -92,11 +164,38 @@
+@@ -92,11 +169,38 @@
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
throw new ReportedException(crashreport);
}
@@ -209,7 +214,7 @@
chunk.loadNearby(this, this.chunkGenerator);
}
-@@ -142,10 +241,12 @@
+@@ -142,10 +246,12 @@
public boolean a(boolean flag) {
int i = 0;
@@ -225,7 +230,7 @@
if (flag) {
this.saveChunkNOP(chunk);
-@@ -170,22 +271,43 @@
+@@ -170,22 +276,43 @@
public boolean unloadChunks() {
if (!this.world.savingDisabled) {
@@ -276,7 +281,7 @@
this.chunkLoader.a();
}
-@@ -198,7 +320,8 @@
+@@ -198,7 +325,8 @@
}
public String getName() {
@@ -286,7 +291,7 @@
}
public List<BiomeBase.BiomeMeta> a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
-@@ -210,10 +333,11 @@
+@@ -210,10 +338,11 @@
}
public int g() {
diff --git a/nms-patches/IChunkProvider.patch b/nms-patches/IChunkProvider.patch
new file mode 100644
index 0000000..a0e6eea
--- /dev/null
+++ b/nms-patches/IChunkProvider.patch
@@ -0,0 +1,9 @@
+--- a/net/minecraft/server/IChunkProvider.java
++++ b/net/minecraft/server/IChunkProvider.java
+@@ -9,4 +9,6 @@
+ boolean unloadChunks();
+
+ String getName();
++
++ Chunk getOrCreateChunkFast(int x, int z); // CraftBukkit
+ }
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 6238eca..3f88db9 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -86,7 +86,12 @@
}
public World b() {
-@@ -197,6 +260,27 @@
+@@ -193,10 +256,31 @@
+ }
+
+ public Chunk getChunkAt(int i, int j) {
+- return this.chunkProvider.getChunkAt(i, j);
++ return this.chunkProvider.getOrCreateChunkFast(i, j); // CraftBukkit
}
public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment