summaryrefslogtreecommitdiffstats
path: root/source/Chunk.cpp
diff options
context:
space:
mode:
authorSamuel Barney <samjbarney@gmail.com>2013-10-21 17:41:48 +0200
committerSamuel Barney <samjbarney@gmail.com>2013-10-21 17:41:48 +0200
commitd73a0cd8b020b0a589e496bed56e6740314d9101 (patch)
tree14b8959ac50a29f38d431c990224b0e784cf7920 /source/Chunk.cpp
parentFixed GetHTMLEscapedString() binding, removed obsolete memory function from API. (diff)
downloadcuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar.gz
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar.bz2
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar.lz
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar.xz
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.tar.zst
cuberite-d73a0cd8b020b0a589e496bed56e6740314d9101.zip
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r--source/Chunk.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp
index 21401163b..944cf82d9 100644
--- a/source/Chunk.cpp
+++ b/source/Chunk.cpp
@@ -539,14 +539,29 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner)
// MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing
// MG TODO : check that "Level" really means Y
- cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, Biome, Try_Y, MaxNbOfSuccess);
- if (newMob)
+ NIBBLETYPE SkyLight = GetSkyLight(Try_X, Try_Y+1, Try_Z);
+ if (!SkyLight)
+ SkyLight = GetSkyLight(Try_X, Try_Y, Try_Z);
+ if (!SkyLight)
+ SkyLight = GetSkyLight(Try_X, Try_Y - 1, Try_Z);
+
+ NIBBLETYPE BlockLight = GetBlockLight(Try_X, Try_Y+1, Try_Z);
+ if (!BlockLight)
+ BlockLight = GetBlockLight(Try_X, Try_Y, Try_Z);
+ if (!BlockLight)
+ BlockLight = GetBlockLight(Try_X, Try_Y - 1, Try_Z);
+
+ if (IsLightValid())
{
- int WorldX, WorldY, WorldZ;
- PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ);
- newMob->SetPosition(WorldX, WorldY, WorldZ);
- LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ);
- NumberOfSuccess++;
+ cEntity* newMob = a_MobSpawner.TryToSpawnHere(BlockType, BlockMeta, BlockType_below, BlockMeta_below, BlockType_above, BlockMeta_above, SkyLight, BlockLight, Biome, Try_Y, MaxNbOfSuccess);
+ if (newMob)
+ {
+ int WorldX, WorldY, WorldZ;
+ PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ);
+ newMob->SetPosition(WorldX, WorldY, WorldZ);
+ LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ);
+ NumberOfSuccess++;
+ }
}
}