summaryrefslogtreecommitdiffstats
path: root/src/MobSpawner.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-04-02 21:26:45 +0200
committerMattes D <github@xoft.cz>2014-04-02 21:26:45 +0200
commite7b8e17746de3b03f16e572bd4f4cd239bcd126a (patch)
tree868c65755c11c2cb8c46968529a57071a69f8eb7 /src/MobSpawner.cpp
parentFixed boat placement code. (diff)
parentWith eXtra line! (diff)
downloadcuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.gz
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.bz2
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.lz
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.xz
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.tar.zst
cuberite-e7b8e17746de3b03f16e572bd4f4cd239bcd126a.zip
Diffstat (limited to 'src/MobSpawner.cpp')
-rw-r--r--src/MobSpawner.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/MobSpawner.cpp b/src/MobSpawner.cpp
index a0d0f5c54..05da5d01c 100644
--- a/src/MobSpawner.cpp
+++ b/src/MobSpawner.cpp
@@ -129,6 +129,11 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
{
+ if ((a_RelY + 1 > cChunkDef::Height) || (a_RelY - 1 < 0))
+ {
+ return false;
+ }
+
NIBBLETYPE BlockLight = a_Chunk->GetBlockLight(a_RelX, a_RelY, a_RelZ);
NIBBLETYPE SkyLight = a_Chunk->GetSkyLight(a_RelX, a_RelY, a_RelZ);
BLOCKTYPE BlockAbove = a_Chunk->GetBlock(a_RelX, a_RelY + 1, a_RelZ);
@@ -200,7 +205,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
case cMonster::mtSpider:
{
bool CanSpawn = true;
- bool HaveFloor = false;
+ bool HasFloor = false;
for (int x = 0; x < 2; ++x)
{
for(int z = 0; z < 2; ++z)
@@ -211,8 +216,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
{
return false;
}
- HaveFloor = (
- HaveFloor ||
+ HasFloor = (
+ HasFloor ||
(
a_Chunk->UnboundedRelGetBlockType(a_RelX + x, a_RelY - 1, a_RelZ + z, TargetBlock) &&
!cBlockInfo::IsTransparent(TargetBlock)
@@ -220,7 +225,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
}
- return CanSpawn && HaveFloor && (SkyLight <= 7) && (BlockLight <= 7);
+ return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
}
case cMonster::mtCreeper: