Ensure chunk neighbor counts do not get desynced
Mojang was not checking that the chunk did not overwrite, or was successfully removed. We're seeing odd reports in #1561 that indicates issues around this are having problems.
This commit is contained in:
@@ -9,7 +9,7 @@ getChunkAt is called for the same chunk multiple times in a row, often from getT
|
||||
Optimize this look up by using a Last Access cache.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkMap.java b/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
index 4b8b77710b..df967ff07d 100644
|
||||
index 4b8b77710b..71ddaf591e 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkMap.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
@@ -20,6 +20,33 @@ index 4b8b77710b..df967ff07d 100644
|
||||
Chunk chunk1 = (Chunk) super.put(i, chunk);
|
||||
ChunkCoordIntPair chunkcoordintpair = new ChunkCoordIntPair(i);
|
||||
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
for (int k = chunkcoordintpair.z - 1; k <= chunkcoordintpair.z + 1; ++k) {
|
||||
if (j != chunkcoordintpair.x || k != chunkcoordintpair.z) {
|
||||
long l = ChunkCoordIntPair.a(j, k);
|
||||
- Chunk chunk2 = (Chunk) this.get(l);
|
||||
+ Chunk chunk2 = (Chunk) super.get(l); // Paper - use super to avoid polluting last access cache
|
||||
|
||||
if (chunk2 != null) {
|
||||
chunk.H();
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
continue;
|
||||
}
|
||||
|
||||
- Chunk neighbor = this.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z));
|
||||
+ Chunk neighbor = super.get(ChunkCoordIntPair.a(chunkcoordintpair.x + x, chunkcoordintpair.z + z)); // Paper - use super to avoid polluting last access cache
|
||||
if (neighbor != null) {
|
||||
neighbor.setNeighborLoaded(-x, -z);
|
||||
chunk.setNeighborLoaded(x, z);
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
for (int j = chunkcoordintpair.x - 1; j <= chunkcoordintpair.x + 1; ++j) {
|
||||
for (int k = chunkcoordintpair.z - 1; k <= chunkcoordintpair.z + 1; ++k) {
|
||||
if (j != chunkcoordintpair.x || k != chunkcoordintpair.z) {
|
||||
- Chunk chunk1 = (Chunk) this.get(ChunkCoordIntPair.a(j, k));
|
||||
+ Chunk chunk1 = (Chunk) super.get(ChunkCoordIntPair.a(j, k)); // Paper - use super to avoid polluting last access cache
|
||||
|
||||
if (chunk1 != null) {
|
||||
chunk1.I();
|
||||
@@ -0,0 +0,0 @@ public class ChunkMap extends Long2ObjectOpenHashMap<Chunk> {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user