diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java index ef6c2a02..60cd87b2 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil113.java @@ -152,9 +152,9 @@ public Section(CompoundTag sectionData) { this.skyLight = sectionData.getByteArray("SkyLight"); this.blocks = sectionData.getLongArray("BlockStates"); - if (blocks.length < 256) blocks = Arrays.copyOf(blocks, 256); - if (blockLight.length < 2048) blockLight = Arrays.copyOf(blockLight, 2048); - if (skyLight.length < 2048) skyLight = Arrays.copyOf(skyLight, 2048); + if (blocks.length < 256 && blocks.length > 0) blocks = Arrays.copyOf(blocks, 256); + if (blockLight.length < 2048 && blockLight.length > 0) blockLight = Arrays.copyOf(blockLight, 2048); + if (skyLight.length < 2048 && skyLight.length > 0) skyLight = Arrays.copyOf(skyLight, 2048); //read block palette ListTag paletteTag = (ListTag) sectionData.getListTag("Palette"); @@ -221,6 +221,8 @@ public BlockState getBlockState(Vector3i pos) { } public LightData getLightData(Vector3i pos) { + if (blockLight.length == 0 && skyLight.length == 0) return LightData.ZERO; + int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; @@ -228,8 +230,8 @@ public LightData getLightData(Vector3i pos) { int blockHalfByteIndex = blockByteIndex >> 1; // blockByteIndex / 2 boolean largeHalf = (blockByteIndex & 0x1) != 0; // (blockByteIndex % 2) == 0 - int blockLight = getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf); - int skyLight = getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf); + int blockLight = this.blockLight.length > 0 ? getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf) : 0; + int skyLight = this.skyLight.length > 0 ? getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf) : 0; return new LightData(skyLight, blockLight); } diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java index 2ebfa8a0..4b36ad1e 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil115.java @@ -153,9 +153,9 @@ public Section(CompoundTag sectionData) { this.skyLight = sectionData.getByteArray("SkyLight"); this.blocks = sectionData.getLongArray("BlockStates"); - if (blocks.length < 256) blocks = Arrays.copyOf(blocks, 256); - if (blockLight.length < 2048) blockLight = Arrays.copyOf(blockLight, 2048); - if (skyLight.length < 2048) skyLight = Arrays.copyOf(skyLight, 2048); + if (blocks.length < 256 && blocks.length > 0) blocks = Arrays.copyOf(blocks, 256); + if (blockLight.length < 2048 && blockLight.length > 0) blockLight = Arrays.copyOf(blockLight, 2048); + if (skyLight.length < 2048 && skyLight.length > 0) skyLight = Arrays.copyOf(skyLight, 2048); //read block palette ListTag paletteTag = (ListTag) sectionData.getListTag("Palette"); @@ -222,6 +222,8 @@ public BlockState getBlockState(Vector3i pos) { } public LightData getLightData(Vector3i pos) { + if (blockLight.length == 0 && skyLight.length == 0) return LightData.ZERO; + int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; @@ -229,8 +231,8 @@ public LightData getLightData(Vector3i pos) { int blockHalfByteIndex = blockByteIndex >> 1; // blockByteIndex / 2 boolean largeHalf = (blockByteIndex & 0x1) != 0; // (blockByteIndex % 2) == 0 - int blockLight = getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf); - int skyLight = getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf); + int blockLight = this.blockLight.length > 0 ? getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf) : 0; + int skyLight = this.skyLight.length > 0 ? getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf) : 0; return new LightData(skyLight, blockLight); } diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java index 0d0d7c1a..bb185642 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/mca/ChunkAnvil116.java @@ -154,9 +154,9 @@ public Section(CompoundTag sectionData) { this.skyLight = sectionData.getByteArray("SkyLight"); this.blocks = sectionData.getLongArray("BlockStates"); - if (blocks.length < 256) blocks = Arrays.copyOf(blocks, 256); - if (blockLight.length < 2048) blockLight = Arrays.copyOf(blockLight, 2048); - if (skyLight.length < 2048) skyLight = Arrays.copyOf(skyLight, 2048); + if (blocks.length < 256 && blocks.length > 0) blocks = Arrays.copyOf(blocks, 256); + if (blockLight.length < 2048 && blockLight.length > 0) blockLight = Arrays.copyOf(blockLight, 2048); + if (skyLight.length < 2048 && skyLight.length > 0) skyLight = Arrays.copyOf(skyLight, 2048); //read block palette ListTag paletteTag = (ListTag) sectionData.getListTag("Palette"); @@ -219,6 +219,8 @@ public BlockState getBlockState(Vector3i pos) { } public LightData getLightData(Vector3i pos) { + if (blockLight.length == 0 && skyLight.length == 0) return LightData.ZERO; + int x = pos.getX() & 0xF; // Math.floorMod(pos.getX(), 16) int y = pos.getY() & 0xF; int z = pos.getZ() & 0xF; @@ -226,8 +228,8 @@ public LightData getLightData(Vector3i pos) { int blockHalfByteIndex = blockByteIndex >> 1; // blockByteIndex / 2 boolean largeHalf = (blockByteIndex & 0x1) != 0; // (blockByteIndex % 2) == 0 - int blockLight = getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf); - int skyLight = getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf); + int blockLight = this.blockLight.length > 0 ? getByteHalf(this.blockLight[blockHalfByteIndex], largeHalf) : 0; + int skyLight = this.skyLight.length > 0 ? getByteHalf(this.skyLight[blockHalfByteIndex], largeHalf) : 0; return new LightData(skyLight, blockLight); }