From ad5356472dd5d1defe6b367b28325c0e6ec76b14 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 27 Jun 2021 23:25:51 -0400 Subject: [PATCH] Create a new cached chunk when a block is created in an empty chunk --- .../connector/network/session/cache/ChunkCache.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java index 9ad0a557b..3687a2c58 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/ChunkCache.java @@ -75,9 +75,18 @@ public class ChunkCache { } 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) {