summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-02-10 11:56:30 +0000
committerDinnerbone <dinnerbone@dinnerbone.com>2011-02-10 11:56:30 +0000
commita52f5ef52057b56024e294194a558f7103eabc15 (patch)
treead3888a9701d6c81a25a2daacd7c65c7eb30b592
parent96794e15db3e91dcf8147ce0824e8ab99d7422d4 (diff)
downloadcraftbukkit-a52f5ef52057b56024e294194a558f7103eabc15.tar
craftbukkit-a52f5ef52057b56024e294194a558f7103eabc15.tar.gz
craftbukkit-a52f5ef52057b56024e294194a558f7103eabc15.tar.lz
craftbukkit-a52f5ef52057b56024e294194a558f7103eabc15.tar.xz
craftbukkit-a52f5ef52057b56024e294194a558f7103eabc15.zip
Threadsafe World.c(int i, int j)
-rw-r--r--src/main/java/net/minecraft/server/World.java15
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