Blocks icon indicating copy to clipboard operation
Blocks copied to clipboard

NPE when generating a chunk

Open rvandoosselaer opened this issue 6 years ago • 0 comments

When using the ChunkPager it happened once that a Chunk was evicted from the ChunkCache while the ChunkManager was still generating the mesh.

This resulted in a NPE in the Chunk class:

public Block getBlock(int x, int y, int z) {
    if (isInsideChunk(x, y, z)) {
        return this.blocks[calculateIndex(x, y, z)];
    }
    ...

the this.blocks variable is null when the chunk is cleaned up.

This doesn't break the functionality since the ChunkPager decided that the chunk should not be rendered (hence the evict). But there is probably a better way to handle this behaviour. All tasks for chunks that are discarded should be aborted.

rvandoosselaer avatar Mar 06 '20 12:03 rvandoosselaer