summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-05-23 11:25:42 +0200
committerMattes D <github@xoft.cz>2014-05-23 11:25:42 +0200
commit64dbc45a00b0c8d24a48293cbd3ff116d7b51735 (patch)
tree857bbe55266e9cc97eb8fc836698692bda51f221 /src/Entities/Entity.cpp
parentUpdated plains village prefabs. (diff)
parentFixed profiling flags for MSVC. (diff)
downloadcuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.gz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.bz2
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.lz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.xz
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.tar.zst
cuberite-64dbc45a00b0c8d24a48293cbd3ff116d7b51735.zip
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r--src/Entities/Entity.cpp24
1 files changed, 24 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);