Skip to content

Commit

Permalink
Create a new cached chunk when a block is created in an empty chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
Camotoy committed Jun 28, 2021
1 parent 215ffc6 commit ad53564
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,18 @@ public void updateBlock(int x, int y, int z, int block) {
}

Chunk chunk = column.getChunks()[(y >> 4) - getChunkMinY()];
if (chunk != null) {
chunk.set(x & 0xF, y & 0xF, z & 0xF, block);
if (chunk == null) {
if (block != BlockTranslator.JAVA_AIR_ID) {
chunk = new Chunk();
// A previously empty chunk, which is no longer empty as a
column.getChunks()[(y >> 4) - getChunkMinY()] = chunk;
} else {
// Nothing to update
return;
}
}

chunk.set(x & 0xF, y & 0xF, z & 0xF, block);
}

public int getBlockAt(int x, int y, int z) {
Expand Down

0 comments on commit ad53564

Please sign in to comment.