diff options
author | Bond-009 <bond.009@outlook.com> | 2017-06-28 10:56:50 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-06-30 23:53:23 +0200 |
commit | a944ac3b067464db026890e27d0c8dced6c8545e (patch) | |
tree | 011b82a81314e63adea957e38ed1b9790c6be8c5 /src/Mobs/Enderman.cpp | |
parent | Spider should attack only when the light level is lower than 11 (#3815) (diff) | |
download | cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar.gz cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar.bz2 cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar.lz cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar.xz cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.tar.zst cuberite-a944ac3b067464db026890e27d0c8dced6c8545e.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Mobs/Enderman.cpp | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/Mobs/Enderman.cpp b/src/Mobs/Enderman.cpp index 3c0717f8f..5cfe0d4cd 100644 --- a/src/Mobs/Enderman.cpp +++ b/src/Mobs/Enderman.cpp @@ -194,14 +194,38 @@ void cEnderman::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) return; } - // TODO take damage in rain - // Take damage when touching water, drowning damage seems to be most appropriate - if (IsSwimming()) + if (CheckRain() || IsSwimming()) { EventLosePlayer(); TakeDamage(dtDrowning, nullptr, 1, 0); // TODO teleport to a safe location } +} + + + + + +bool cEnderman::CheckRain(void) +{ + if (!GetWorld()->IsWeatherRain()) + { + return false; + } + Vector3d coords = GetPosition(); + for (int Y = static_cast<int>(coords.y); Y < cChunkDef::Height; ++Y) + { + BLOCKTYPE Block = m_World->GetBlock(static_cast<int>(coords.x), Y, static_cast<int>(coords.z)); + if (Block != E_BLOCK_AIR) + { + return false; + } + } + return true; } + + + + |