Set last accessed variables after grabbing chunk. Fixes BUKKIT-1033

This fix changes the 'state' of the last accessed variables to be more
accurate. Changing the coordinates of the last accessed chunk should
never precede actually setting the last accessed chunk, as loading a
chunk may at some point call back to getChunkAt with a new set of
coordinates before the chunk has actually been loaded. The coordinates
would have been set, but the actual chunk would not. With no check for
accuracy, this causes fringe case issues such as null block states.

Big thanks to @V10lator for finding where the root of the problem was
occurring.
This commit is contained in:
Wesley Wolfe 2012-09-20 23:00:34 -05:00
parent cebc8cffec
commit 9f70c1f386

View file

@ -223,9 +223,9 @@ public abstract class World implements IBlockAccess {
Chunk result = null;
synchronized (this.chunkLock) {
if (this.lastChunkAccessed == null || this.lastXAccessed != i || this.lastZAccessed != j) {
this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
this.lastXAccessed = i;
this.lastZAccessed = j;
this.lastChunkAccessed = this.chunkProvider.getOrCreateChunk(i, j);
}
result = this.lastChunkAccessed;
}