diff options
author | Alexander Harkness <bearbin@gmail.com> | 2014-05-19 15:01:50 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2014-05-19 15:01:50 +0200 |
commit | 1de4408a1809a312f4c63065d6538a422c6a9326 (patch) | |
tree | c93b4e6e9b28b9a80e87252a3ef0de19dbb8868e /src/Entities | |
parent | There's no "round" function in MSVC2008. (diff) | |
parent | Derp (diff) | |
download | cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar.gz cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar.bz2 cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar.lz cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar.xz cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.tar.zst cuberite-1de4408a1809a312f4c63065d6538a422c6a9326.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Entity.cpp | 24 | ||||
-rw-r--r-- | src/Entities/Entity.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 31ad66779..15f456332 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -617,6 +617,10 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk) m_TicksSinceLastVoidDamage = 0; } + if (IsMob() || IsPlayer() || IsPickup() || IsExpOrb()) + { + DetectCacti(); + } if (IsMob() || IsPlayer()) { // Set swimming state @@ -1014,6 +1018,26 @@ void cEntity::TickInVoid(cChunk & a_Chunk) +void cEntity::DetectCacti() +{ + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; + float w = m_Width / 2; + if ( + (((X + 1) - GetPosX() < w) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS)) || + (((GetPosX() - (X - 1)) - 1 < w) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS)) || + (((Z + 1) - GetPosZ() < w) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS)) || + (((GetPosZ() - (Z - 1)) - 1 < w) && (GetWorld()->GetBlock(X, Y, Z - 1) == E_BLOCK_CACTUS)) || + (((Y > 0) && (Y < cChunkDef::Height)) && ((GetPosY() - Y < 1) && (GetWorld()->GetBlock(X, Y, Z) == E_BLOCK_CACTUS))) + ) + { + TakeDamage(dtCactusContact, NULL, 1, 0); + } +} + + + + + void cEntity::SetSwimState(cChunk & a_Chunk) { int RelY = (int)floor(GetPosY() + 0.1); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index a111b128d..0c393c0f5 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -320,6 +320,9 @@ public: /// Updates the state related to this entity being on fire virtual void TickBurning(cChunk & a_Chunk); + + /** Detects the time for application of cacti damage */ + virtual void DetectCacti(void); /// Handles when the entity is in the void virtual void TickInVoid(cChunk & a_Chunk); |