summaryrefslogtreecommitdiffstats
path: root/source/MobSpawner.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2013-10-29 17:44:51 +0100
committerSamuel Barney <samjbarney@gmail.com>2013-10-29 17:44:51 +0100
commite1a06153b2e93473af58e1d801998ff7f388dc6d (patch)
tree080e0f9744333fe7936bcda1da47757dfa9fb10f /source/MobSpawner.cpp
parentMerge branch 'master' of https://github.com/SamJBarney/MCServer into MobSpawning (diff)
downloadcuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.gz
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.bz2
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.lz
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.xz
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.tar.zst
cuberite-e1a06153b2e93473af58e1d801998ff7f388dc6d.zip
Diffstat (limited to '')
-rw-r--r--source/MobSpawner.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/source/MobSpawner.cpp b/source/MobSpawner.cpp
index 7dff56d61..7c7b25b60 100644
--- a/source/MobSpawner.cpp
+++ b/source/MobSpawner.cpp
@@ -124,7 +124,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
-bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, int a_TimeOfDay, EMCSBiome a_Biome)
+bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
{
BLOCKTYPE TargetBlock;
BLOCKTYPE BlockAbove;
@@ -138,13 +138,16 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
a_Chunk->UnboundedRelGetBlockSkyLight(a_RelX, a_RelY, a_RelZ, SkyLight);
a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 1, a_RelZ, BlockAbove);
a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY - 1, a_RelZ, BlockBelow);
+
+ SkyLight = a_Chunk->GetTimeAlteredLight(SkyLight);
+
switch(a_MobType)
{
case cMonster::mtSquid:
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
case cMonster::mtBat:
- return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4 || a_TimeOfDay > 12500) && (TargetBlock == E_BLOCK_AIR) && (!g_BlockTransparent[BlockAbove]);
+ return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && (!g_BlockTransparent[BlockAbove]);
case cMonster::mtChicken:
case cMonster::mtCow:
@@ -153,7 +156,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
case cMonster::mtSheep:
{
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
- (BlockBelow == E_BLOCK_GRASS) && (SkyLight >= 9) && (a_TimeOfDay <= 12500);
+ (BlockBelow == E_BLOCK_GRASS) && (SkyLight >= 9);
}
case cMonster::mtOcelot:
@@ -167,8 +170,12 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
{
BLOCKTYPE BlockTop;
a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 2, a_RelZ, BlockTop);
- return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (BlockTop == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
- ((SkyLight <= 7) || a_TimeOfDay > 12500 ) && (BlockLight <= 7) ;
+ if (BlockTop == E_BLOCK_AIR)
+ {
+ a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY + 3, a_RelZ, BlockTop);
+ return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (BlockTop == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
+ (SkyLight <= 7) && (BlockLight <= 7);
+ }
}
break;
}
@@ -193,13 +200,13 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
}
}
}
- return CanSpawn && HaveFloor && ((SkyLight <= 7) || a_TimeOfDay > 12500) && (BlockLight <= 7);
+ return CanSpawn && HaveFloor && (SkyLight <= 7) && (BlockLight <= 7);
}
case cMonster::mtCreeper:
case cMonster::mtZombie:
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
- ((SkyLight <= 7) || a_TimeOfDay > 12500) && (BlockLight <= 7) && (m_Random.NextInt(2,a_Biome) == 0);
+ (SkyLight <= 7) && (BlockLight <= 7) && (m_Random.NextInt(2,a_Biome) == 0);
case cMonster::mtSlime:
return (TargetBlock == E_BLOCK_AIR) && (BlockAbove == E_BLOCK_AIR) && (!g_BlockTransparent[BlockBelow]) &&
@@ -220,7 +227,7 @@ bool cMobSpawner::CanSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, i
-cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int a_TimeOfDay, int& a_MaxPackSize)
+cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, EMCSBiome a_Biome, int& a_MaxPackSize)
{
cMonster* toReturn = NULL;
if (m_NewPack)
@@ -242,7 +249,7 @@ cMonster* cMobSpawner::TryToSpawnHere(const cChunk * a_Chunk, int a_RelX, int a_
}
- if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_TimeOfDay, a_Biome))
+ if (CanSpawnHere(a_Chunk, a_RelX, a_RelY, a_RelZ, m_MobType, a_Biome))
{
cMonster * newMob = cMonster::NewMonsterFromType(m_MobType);
if (newMob)