summaryrefslogtreecommitdiffstats
path: root/src/Section.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-09-24 17:58:06 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:32 +0100
commit6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f (patch)
tree4055e47d4285d63e01a54b16650b2df6c382dc2c /src/Section.cpp
parent2017-09-23 (diff)
downloadAltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar.gz
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar.bz2
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar.lz
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar.xz
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.tar.zst
AltCraft-6d1aef5ba39a7b16e8de7d5f25a6ecf53c97e71f.zip
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);