summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockDirt.h
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-12-13 13:12:35 +0100
committerHowaner <franzi.moos@googlemail.com>2014-12-13 13:12:35 +0100
commit426a60320061f0d59b763b826c5dd5802fec68e8 (patch)
tree72a01e56d472177c43f182747a467f67744f63ef /src/Blocks/BlockDirt.h
parentMerge branch 'master' into BlockFixes (diff)
downloadcuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar.gz
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar.bz2
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar.lz
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar.xz
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.tar.zst
cuberite-426a60320061f0d59b763b826c5dd5802fec68e8.zip
Diffstat (limited to '')
-rw-r--r--src/Blocks/BlockDirt.h25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Blocks/BlockDirt.h b/src/Blocks/BlockDirt.h
index aae6719e2..69768396b 100644
--- a/src/Blocks/BlockDirt.h
+++ b/src/Blocks/BlockDirt.h
@@ -55,29 +55,32 @@ public:
// Grass spreads to adjacent dirt blocks:
cFastRandom rand;
- for (int i = 0; i < 2; i++) // Pick two blocks to grow to
+ for (int i = 0; i < 3; i++) // Pick three blocks to grow to
{
- int OfsX = rand.NextInt(3, a_RelX) - 1; // [-1 .. 1]
- int OfsY = rand.NextInt(5, a_RelY) - 3; // [-3 .. 1]
- int OfsZ = rand.NextInt(3, a_RelZ) - 1; // [-1 .. 1]
-
- BLOCKTYPE DestBlock;
- NIBBLETYPE DestMeta;
- if ((a_RelY + OfsY < 0) || (a_RelY + OfsY >= cChunkDef::Height - 1))
+ int OfsX = rand.GenerateRandomInteger(-1, 1);
+ int OfsY = rand.GenerateRandomInteger(-3, 1);
+ int OfsZ = rand.GenerateRandomInteger(-1, 1);
+ int BlockX = a_RelX + OfsX;
+ int BlockY = a_RelY + OfsY;
+ int BlockZ = a_RelZ + OfsZ;
+
+ if ((BlockY < 0) || (BlockY >= cChunkDef::Height))
{
// Y Coord out of range
continue;
}
- int BlockX = a_RelX + OfsX;
- int BlockY = a_RelY + OfsY;
- int BlockZ = a_RelZ + OfsZ;
+
cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(BlockX, BlockZ);
if (Chunk == nullptr)
{
// Unloaded chunk
continue;
}
+
+ BLOCKTYPE DestBlock;
+ NIBBLETYPE DestMeta;
Chunk->GetBlockTypeMeta(BlockX, BlockY, BlockZ, DestBlock, DestMeta);
+
if ((DestBlock != E_BLOCK_DIRT) || (DestMeta != E_META_DIRT_NORMAL))
{
// Not a regular dirt block