From c4e6a1423506c253974c7512a4b9b854a1e41b54 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 30 Jul 2014 19:18:11 +0200 Subject: Added lighting code and added comments --- src/Mobs/Enderman.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 9c1cb7ce3..f1f366d3b 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -116,6 +116,23 @@ void cEnderman::CheckEventSeePlayer() ASSERT(Callback.GetPlayer() != NULL); + int ChunkX, ChunkZ; + cChunkDef::BlockToChunk(POSX_TOINT, POSZ_TOINT, ChunkX, ChunkZ); + + // Check if the chunk the enderman is in is lit. + if (!m_World->IsChunkLighted(ChunkX, ChunkZ)) + { + m_World->QueueLightChunk(ChunkX, ChunkZ); + return; + } + + // Enderman only attack if the skylight is higher than 6 + if (m_World->GetBlockSkyLight(POSX_TOINT, POSY_TOINT, POSZ_TOINT) <= 7) + { + // TODO: Teleport the enderman to a random spot. + return; + } + if (!Callback.GetPlayer()->IsGameModeCreative()) { super::EventSeePlayer(Callback.GetPlayer()); -- cgit v1.2.3