3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

SPIGOT-1626 / MC-98994: Fix slow chunk performance

Please see https://bugs.mojang.com/browse/MC-98994 for full explanation.
Dieser Commit ist enthalten in:
md_5 2016-03-05 18:50:38 +11:00
Ursprung 94ba824302
Commit 60f01ef304
3 geänderte Dateien mit 27 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -79,11 +79,16 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Chunk chunk = (Chunk) iterator.next(); Chunk chunk = (Chunk) iterator.next();
@@ -49,11 +70,15 @@ @@ -49,11 +70,20 @@
} }
+ // CraftBukkit start - Add async variant, provide compatibility + // 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) { + public Chunk getChunkIfLoaded(int x, int z) {
+ return chunks.get(LongHash.toLong(x, z)); + return chunks.get(LongHash.toLong(x, z));
+ } + }
@ -98,7 +103,7 @@
return chunk; return chunk;
} }
@@ -61,20 +86,67 @@ @@ -61,20 +91,67 @@
Chunk chunk = this.getLoadedChunkAt(i, j); Chunk chunk = this.getLoadedChunkAt(i, j);
if (chunk == null) { if (chunk == null) {
@ -168,7 +173,7 @@
if (chunk == null) { if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j); long k = ChunkCoordIntPair.a(i, j);
@@ -92,11 +164,38 @@ @@ -92,11 +169,38 @@
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator); crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
@ -209,7 +214,7 @@
chunk.loadNearby(this, this.chunkGenerator); chunk.loadNearby(this, this.chunkGenerator);
} }
@@ -142,10 +241,12 @@ @@ -142,10 +246,12 @@
public boolean a(boolean flag) { public boolean a(boolean flag) {
int i = 0; int i = 0;
@ -225,7 +230,7 @@
if (flag) { if (flag) {
this.saveChunkNOP(chunk); this.saveChunkNOP(chunk);
@@ -170,22 +271,43 @@ @@ -170,22 +276,43 @@
public boolean unloadChunks() { public boolean unloadChunks() {
if (!this.world.savingDisabled) { if (!this.world.savingDisabled) {
@ -276,7 +281,7 @@
this.chunkLoader.a(); this.chunkLoader.a();
} }
@@ -198,7 +320,8 @@ @@ -198,7 +325,8 @@
} }
public String getName() { public String getName() {
@ -286,7 +291,7 @@
} }
public List<BiomeBase.BiomeMeta> a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) { public List<BiomeBase.BiomeMeta> a(EnumCreatureType enumcreaturetype, BlockPosition blockposition) {
@@ -210,10 +333,11 @@ @@ -210,10 +338,11 @@
} }
public int g() { public int g() {

Datei anzeigen

@ -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
}

Datei anzeigen

@ -86,7 +86,12 @@
} }
public World b() { 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) { public boolean setTypeAndData(BlockPosition blockposition, IBlockData iblockdata, int i) {