diff options
-rw-r--r-- | src/main/java/net/minecraft/server/World.java | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java index be0b8e22..9a1c5a28 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -286,13 +286,18 @@ public class World implements IBlockAccess { Chunk lastChunkAccessed; int lastXAccessed = Integer.MIN_VALUE; int lastZAccessed = Integer.MIN_VALUE; + final Object chunkLock = new Object(); public Chunk c(int i, int j) { - if(lastChunkAccessed == null || lastXAccessed != i || lastZAccessed != j) { - lastXAccessed = i; - lastZAccessed = j; - lastChunkAccessed = this.G.b(i, j); + Chunk result = null; + synchronized (chunkLock) { + if (lastChunkAccessed == null || lastXAccessed != i || lastZAccessed != j) { + lastXAccessed = i; + lastZAccessed = j; + lastChunkAccessed = this.G.b(i, j); + } + result = lastChunkAccessed; } - return lastChunkAccessed; + return result; } // CraftBukkit end |