Fixed issue in ChunkIO that would potentially cause NPEs on chunks. Closes #2837

This commit is contained in:
LexManos 2016-05-09 02:10:24 -07:00
parent a7d5820e99
commit d30aae862f
2 changed files with 15 additions and 10 deletions

View File

@ -47,9 +47,9 @@ public class ChunkIOExecutor
{
if (!pool.remove(task)) // If it wasn't in the pool, and run hasn't finished, then wait for the async thread.
{
while (!task.runFinished())
synchronized(task)
{
synchronized(task)
while (!task.runFinished())
{
try
{

View File

@ -67,7 +67,8 @@ class ChunkIOProvider implements Runnable
if (chunk == null)
{
// If the chunk loading failed just do it synchronously (may generate)
provider.originalLoadChunk(this.chunkInfo.x, this.chunkInfo.z);
this.chunk = provider.originalLoadChunk(this.chunkInfo.x, this.chunkInfo.z);
this.runCallbacks();
return;
}
@ -87,13 +88,7 @@ class ChunkIOProvider implements Runnable
}
this.chunk.populateChunk(provider, provider.chunkGenerator);
for (Runnable r : this.callbacks)
{
r.run();
}
this.callbacks.clear();
this.runCallbacks();
}
public Chunk getChunk()
@ -110,4 +105,14 @@ class ChunkIOProvider implements Runnable
{
return this.callbacks.size() > 0;
}
public void runCallbacks()
{
for (Runnable r : this.callbacks)
{
r.run();
}
this.callbacks.clear();
}
}