Fixed issue in ChunkIO that would potentially cause NPEs on chunks. Closes #2837
This commit is contained in:
parent
a7d5820e99
commit
d30aae862f
2 changed files with 15 additions and 10 deletions
|
@ -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.
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -67,7 +67,8 @@ class ChunkIOProvider implements Runnable
|
||||||
if (chunk == null)
|
if (chunk == null)
|
||||||
{
|
{
|
||||||
// If the chunk loading failed just do it synchronously (may generate)
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,13 +88,7 @@ class ChunkIOProvider implements Runnable
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chunk.populateChunk(provider, provider.chunkGenerator);
|
this.chunk.populateChunk(provider, provider.chunkGenerator);
|
||||||
|
this.runCallbacks();
|
||||||
for (Runnable r : this.callbacks)
|
|
||||||
{
|
|
||||||
r.run();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.callbacks.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Chunk getChunk()
|
public Chunk getChunk()
|
||||||
|
@ -110,4 +105,14 @@ class ChunkIOProvider implements Runnable
|
||||||
{
|
{
|
||||||
return this.callbacks.size() > 0;
|
return this.callbacks.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runCallbacks()
|
||||||
|
{
|
||||||
|
for (Runnable r : this.callbacks)
|
||||||
|
{
|
||||||
|
r.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.callbacks.clear();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue