summaryrefslogtreecommitdiffstats
path: root/src/Section.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Section.cpp')
-rw-r--r--src/Section.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/Section.cpp b/src/Section.cpp
index e6b6d93..c105b06 100644
--- a/src/Section.cpp
+++ b/src/Section.cpp
@@ -112,6 +112,9 @@ BlockId Section::GetBlockId(Vector pos) const {
unsigned char Section::GetBlockLight(Vector pos) const
{
+ if (light.empty())
+ return 0;
+
int blockNumber = pos.y * 256 + pos.z * 16 + pos.x;
unsigned char lightValue = this->light[blockNumber / 2];
return (blockNumber % 2 == 0) ? (lightValue & 0xF) : (lightValue >> 4);
@@ -119,6 +122,9 @@ unsigned char Section::GetBlockLight(Vector pos) const
unsigned char Section::GetBlockSkyLight(Vector pos) const
{
+ if (sky.empty())
+ return 0;
+
int blockNumber = pos.y * 256 + pos.z * 16 + pos.x;
unsigned char skyValue = this->sky[blockNumber / 2];
return (blockNumber % 2 == 0) ? (skyValue & 0xF) : (skyValue >> 4);