mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-14 19:55:52 -07:00
SPIGOT-1626 / MC-98994: Fix slow chunk performance
Please see https://bugs.mojang.com/browse/MC-98994 for full explanation.
This commit is contained in:
@@ -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() {
|
||||
|
Reference in New Issue
Block a user