summaryrefslogtreecommitdiffstats
path: root/src/Blocks
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2020-03-30 19:23:25 +0200
committerAlexander Harkness <me@bearbin.net>2020-03-30 19:23:25 +0200
commit52d5760be17235a1811e9a26ce849c4a33afad72 (patch)
treec31178adcb16b7668bd28d83a4e2974072c02379 /src/Blocks
parentUpdate GETTING-STARTED.md (#4581) (diff)
downloadcuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar.gz
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar.bz2
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar.lz
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar.xz
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.tar.zst
cuberite-52d5760be17235a1811e9a26ce849c4a33afad72.zip
Diffstat (limited to 'src/Blocks')
-rw-r--r--src/Blocks/BlockGrass.h6
-rw-r--r--src/Blocks/BlockPlant.h17
2 files changed, 7 insertions, 16 deletions
diff --git a/src/Blocks/BlockGrass.h b/src/Blocks/BlockGrass.h
index 0e54cb092..341a44b07 100644
--- a/src/Blocks/BlockGrass.h
+++ b/src/Blocks/BlockGrass.h
@@ -60,9 +60,8 @@ public:
return;
}
- NIBBLETYPE light = std::max(a_Chunk.GetBlockLight(a_RelX, a_RelY + 1, a_RelZ), a_Chunk.GetTimeAlteredLight(a_Chunk.GetSkyLight(a_RelX, a_RelY + 1, a_RelZ)));
// Source block is not bright enough to spread
- if (light < 9)
+ if (a_Chunk.GetLightAltered(Vector3i(a_RelX, a_RelY + 1, a_RelZ)) < 9)
{
return;
}
@@ -99,8 +98,7 @@ public:
}
auto abovePos = pos.addedY(1);
BLOCKTYPE above = chunk->GetBlock(abovePos);
- NIBBLETYPE light = std::max(chunk->GetBlockLight(abovePos), chunk->GetTimeAlteredLight(chunk->GetSkyLight(abovePos)));
- if ((light > 4) &&
+ if ((a_Chunk.GetLightAltered(abovePos) > 4) &&
cBlockInfo::IsTransparent(above) &&
(!IsBlockLava(above)) &&
(!IsBlockWaterOrIce(above))
diff --git a/src/Blocks/BlockPlant.h b/src/Blocks/BlockPlant.h
index 0e249bbde..d71614cdb 100644
--- a/src/Blocks/BlockPlant.h
+++ b/src/Blocks/BlockPlant.h
@@ -77,26 +77,19 @@ protected:
{
return paGrowth;
}
- NIBBLETYPE Blocklight = a_Chunk.GetBlockLight(a_RelPos);
- NIBBLETYPE SkyLight = a_Chunk.GetSkyLight (a_RelPos);
- NIBBLETYPE Light = a_Chunk.GetTimeAlteredLight(SkyLight);
-
- // If the amount of light provided by blocks is greater than the sky light, use it instead
- if (Blocklight > Light)
- {
- Light = Blocklight;
- }
// Based on light levels, decide between growth, stay and death:
- if (Light > 8)
+ // Grow if the combined adjusted light above is bright enough.
+ if (a_Chunk.GetLightAltered(a_RelPos + Vector3i(0, 1, 0)) > 8)
{
return paGrowth;
}
- else if ((Blocklight < 9) && (SkyLight < 9))
+ // Die if the combined non-adjusted light inside is dark enough.
+ if (a_Chunk.GetLight(a_RelPos) < 8)
{
return paDeath;
}
-
+ // Otherwise stay the same.
return paStay;
}