3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00

SPIGOT-2297: Reintroduce getChunkIfLoaded

Dieser Commit ist enthalten in:
md_5 2016-05-22 11:36:38 +10:00
Ursprung d8637dfb7e
Commit 8982e3f33e

Datei anzeigen

@ -18,7 +18,7 @@
public final ChunkGenerator chunkGenerator;
private final IChunkLoader chunkLoader;
public final Long2ObjectMap<Chunk> chunks = new Long2ObjectOpenHashMap(8192);
@@ -69,19 +75,68 @@
@@ -69,19 +75,74 @@
Chunk chunk = this.getLoadedChunkAt(i, j);
if (chunk == null) {
@ -45,6 +45,12 @@
return chunk;
}
+ // CraftBukkit start
+ public Chunk getChunkIfLoaded(int x, int z) {
+ return chunks.get(ChunkCoordIntPair.a(x, z));
+ }
+ // CraftBukkit end
+
public Chunk getChunkAt(int i, int j) {
- Chunk chunk = this.getOrLoadChunkAt(i, j);
+ return getChunkAt(i, j, null);
@ -55,7 +61,7 @@
+ }
+
+ public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) {
+ Chunk chunk = chunks.get(ChunkCoordIntPair.a(i, j));
+ Chunk chunk = getChunkIfLoaded(i, j);
+ ChunkRegionLoader loader = null;
+
+ if (this.chunkLoader instanceof ChunkRegionLoader) {
@ -89,7 +95,7 @@
if (chunk == null) {
long k = ChunkCoordIntPair.a(i, j);
@@ -97,9 +152,37 @@
@@ -97,9 +158,37 @@
crashreportsystemdetails.a("Generator", (Object) this.chunkGenerator);
throw new ReportedException(crashreport);
}
@ -116,7 +122,7 @@
+ continue;
+ }
+
+ Chunk neighbor = this.getLoadedChunkAt(chunk.locX + x, chunk.locZ + z);
+ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
+ if (neighbor != null) {
+ neighbor.setNeighborLoaded(-x, -z);
+ chunk.setNeighborLoaded(x, z);
@ -127,7 +133,7 @@
chunk.loadNearby(this, this.chunkGenerator);
}
@@ -146,10 +229,12 @@
@@ -146,10 +235,12 @@
public boolean a(boolean flag) {
int i = 0;
@ -143,7 +149,7 @@
if (flag) {
this.saveChunkNOP(chunk);
@@ -182,6 +267,29 @@
@@ -182,6 +273,29 @@
Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) {
@ -161,7 +167,7 @@
+ continue;
+ }
+
+ Chunk neighbor = this.chunks.get(ChunkCoordIntPair.a(chunk.locX + x, chunk.locZ + z));
+ Chunk neighbor = this.getChunkIfLoaded(chunk.locX + x, chunk.locZ + z);
+ if (neighbor != null) {
+ neighbor.setNeighborUnloaded(-x, -z);
+ chunk.setNeighborUnloaded(x, z);