diff options
author | Mattes D <github@xoft.cz> | 2013-10-30 23:25:51 +0100 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2013-10-30 23:25:51 +0100 |
commit | 8b9d3c77228b139d5b5a146e0f1aa242e3066903 (patch) | |
tree | 6733363192eb368c335e9aa18fd0df2ab4a266b7 /source/Chunk.cpp | |
parent | Added 1.7 to protocol recognizer. (diff) | |
parent | Last of the nitpicker note fixes. Added some inline commenting. (diff) | |
download | cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.gz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.bz2 cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.lz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.xz cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.tar.zst cuberite-8b9d3c77228b139d5b5a146e0f1aa242e3066903.zip |
Diffstat (limited to 'source/Chunk.cpp')
-rw-r--r-- | source/Chunk.cpp | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/source/Chunk.cpp b/source/Chunk.cpp index c9d457af3..be75eae41 100644 --- a/source/Chunk.cpp +++ b/source/Chunk.cpp @@ -519,32 +519,28 @@ void cChunk::SpawnMobs(cMobSpawner& a_MobSpawner) ASSERT(Try_Y > 0); ASSERT(Try_Y < cChunkDef::Height-1); - BLOCKTYPE BlockType; - NIBBLETYPE BlockMeta; - BLOCKTYPE BlockType_below; - NIBBLETYPE BlockMeta_below; - BLOCKTYPE BlockType_above; - NIBBLETYPE BlockMeta_above; - if (UnboundedRelGetBlock(Try_X, Try_Y , Try_Z, BlockType, BlockMeta) && - UnboundedRelGetBlock(Try_X, Try_Y-1, Try_Z, BlockType_below, BlockMeta_below)&& - UnboundedRelGetBlock(Try_X, Try_Y+1, Try_Z, BlockType_above, BlockMeta_above) - ) - { - EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z); - // MG TODO : - // Moon cycle (for slime) - // check player and playerspawn presence < 24 blocks - // check mobs presence on the block + EMCSBiome Biome = m_ChunkMap->GetBiomeAt (Try_X, Try_Z); + // MG TODO : + // Moon cycle (for slime) + // check player and playerspawn presence < 24 blocks + // check mobs presence on the block + + // MG TODO : check that "Level" really means Y + + NIBBLETYPE SkyLight = 0; - // MG TODO: fix the "light" thing, I'm pretty sure that UnboundedRelGetBlock s not returning the right thing + NIBBLETYPE BlockLight = 0; - // 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 (IsLightValid()) + { + cEntity* newMob = a_MobSpawner.TryToSpawnHere(this, Try_X, Try_Y, Try_Z, Biome, MaxNbOfSuccess); if (newMob) { int WorldX, WorldY, WorldZ; PositionToWorldPosition(Try_X, Try_Y, Try_Z, WorldX, WorldY, WorldZ); - newMob->SetPosition(WorldX, WorldY, WorldZ); + double ActualX = WorldX + 0.5; + double ActualZ = WorldZ + 0.5; + newMob->SetPosition(ActualX, WorldY, ActualZ); LOGD("Spawning %s #%i at %d,%d,%d",newMob->GetClass(),newMob->GetUniqueID(),WorldX, WorldY, WorldZ); NumberOfSuccess++; } @@ -2790,6 +2786,17 @@ Vector3i cChunk::PositionToWorldPosition(int a_RelX, int a_RelY, int a_RelZ) +NIBBLETYPE cChunk::GetTimeAlteredLight(NIBBLETYPE a_Skylight) const +{ + a_Skylight -= m_World->GetSkyDarkness(); + // Because NIBBLETYPE is unsigned, we clamp it to 0 .. 15 by checking for values above 15 + return (a_Skylight < 16)? a_Skylight : 0; +} + + + + + #if !C_CHUNK_USE_INLINE # include "cChunk.inl.h" #endif |