diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-05-18 23:41:42 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-05-18 23:41:42 +0200 |
commit | 6167c79e7a822cb14431985a82f4cc5b463e556f (patch) | |
tree | c15864c1c047290ac29745a0e1fd8b00947c029a /src/Entities | |
parent | Merge pull request #1005 from SphinxC0re/LoadPluginfolder (diff) | |
download | cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar.gz cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar.bz2 cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar.lz cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar.xz cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.tar.zst cuberite-6167c79e7a822cb14431985a82f4cc5b463e556f.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Entity.cpp | 23 | ||||
-rw-r--r-- | src/Entities/Entity.h | 3 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 4cf10a219..b7cb2c3d9 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -601,6 +601,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 @@ -998,6 +1002,25 @@ void cEntity::TickInVoid(cChunk & a_Chunk) +void cEntity::DetectCacti() +{ + int X = POSX_TOINT, Y = POSY_TOINT, Z = POSZ_TOINT; + if ( + ((X + 1) - GetPosX() < 0.3) && (GetWorld()->GetBlock(X + 1, Y, Z) == E_BLOCK_CACTUS) || + ((GetPosX() - (X - 1)) - 1 < 0.3) && (GetWorld()->GetBlock(X - 1, Y, Z) == E_BLOCK_CACTUS) || + ((Z + 1) - GetPosZ() < 0.3) && (GetWorld()->GetBlock(X, Y, Z + 1) == E_BLOCK_CACTUS) || + ((GetPosZ() - (Z - 1)) - 1 < 0.3) && (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(dtCactus, 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 df03d635b..d5e7cf5c1 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -317,6 +317,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); |