From 1a0f7df3f4ba489d052ef0d6c0d9649f0d400668 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Mon, 23 Aug 2021 13:08:10 +0100 Subject: [PATCH] Fix #1243 --- .../implementation/chunk/ChunkHolder.java | 40 +++++++++++-------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java index 5f1dab37b..0e9144dea 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/chunk/ChunkHolder.java @@ -286,10 +286,12 @@ public class ChunkHolder> implements IQueueChunk { if (chunk.chunkSet.getSkyLight() != null) { int layer = y >> 4; layer -= chunk.chunkSet.getMinSectionIndex(); - if (chunk.chunkSet.getSkyLight()[layer] != null) { - int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; - if (setLightValue < 16) { - return setLightValue; + if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) { + if (chunk.chunkSet.getSkyLight()[layer] != null) { + int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; + if (setLightValue < 16) { + return setLightValue; + } } } } @@ -301,10 +303,12 @@ public class ChunkHolder> implements IQueueChunk { if (chunk.chunkSet.getLight() != null) { int layer = y >> 4; layer -= chunk.chunkSet.getMinSectionIndex(); - if (chunk.chunkSet.getLight()[layer] != null) { - int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; - if (setLightValue < 16) { - return setLightValue; + if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) { + if (chunk.chunkSet.getLight()[layer] != null) { + int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; + if (setLightValue < 16) { + return setLightValue; + } } } } @@ -598,10 +602,12 @@ public class ChunkHolder> implements IQueueChunk { if (chunk.chunkSet.getSkyLight() != null) { int layer = y >> 4; layer -= chunk.chunkSet.getMinSectionIndex(); - if (chunk.chunkSet.getSkyLight()[layer] != null) { - int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; - if (setLightValue < 16) { - return setLightValue; + if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) { + if (chunk.chunkSet.getSkyLight()[layer] != null) { + int setLightValue = chunk.chunkSet.getSkyLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; + if (setLightValue < 16) { + return setLightValue; + } } } } @@ -616,10 +622,12 @@ public class ChunkHolder> implements IQueueChunk { if (chunk.chunkSet.getLight() != null) { int layer = y >> 4; layer -= chunk.chunkSet.getMinSectionIndex(); - if (chunk.chunkSet.getLight()[layer] != null) { - int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; - if (setLightValue < 16) { - return setLightValue; + if (layer >= 0 && layer < chunk.chunkSet.getSectionCount()) { + if (chunk.chunkSet.getLight()[layer] != null) { + int setLightValue = chunk.chunkSet.getLight()[layer][(y & 15) << 8 | (z & 15) << 4 | (x & 15)]; + if (setLightValue < 16) { + return setLightValue; + } } } }