The chunk caching method is now thread safe

This commit is contained in:
themode 2020-09-02 18:35:17 +02:00
parent 6e9e6be1fe
commit 623a6eb783

View File

@ -517,9 +517,16 @@ public class InstanceContainer extends Instance {
this.sharedInstances.add(sharedInstance);
}
/**
* Add a {@link Chunk} to the internal instance map
*
* @param chunk the chunk to cache
*/
private void cacheChunk(Chunk chunk) {
final long index = ChunkUtils.getChunkIndex(chunk.getChunkX(), chunk.getChunkZ());
this.chunks.put(index, chunk);
synchronized (chunks) {
this.chunks.put(index, chunk);
}
}
@Override