summaryrefslogtreecommitdiffstats
path: root/source/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2013-09-11 00:01:02 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2013-09-11 00:01:02 +0200
commitc8f8597774c47e755597eae4a120bea9479d0479 (patch)
treee58bf41015675934698431f81007e4de8e62697c /source/Entities
parentEntities now maintain speed outside of world (diff)
downloadcuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar.gz
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar.bz2
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar.lz
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar.xz
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.tar.zst
cuberite-c8f8597774c47e755597eae4a120bea9479d0479.zip
Diffstat (limited to 'source/Entities')
-rw-r--r--source/Entities/Entity.cpp23
-rw-r--r--source/Entities/Entity.h6
2 files changed, 29 insertions, 0 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index 0aaa2e899..846d756dd 100644
--- a/source/Entities/Entity.cpp
+++ b/source/Entities/Entity.cpp
@@ -55,6 +55,7 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d
, m_TicksSinceLastBurnDamage(0)
, m_TicksSinceLastLavaDamage(0)
, m_TicksSinceLastFireDamage(0)
+ , m_TicksSinceLastVoidDamage(0)
, m_TicksLeftBurning(0)
, m_WaterSpeed(0, 0, 0)
, m_Width(a_Width)
@@ -472,6 +473,11 @@ void cEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
TickBurning(a_Chunk);
}
+ if ((a_Chunk.IsValid()) && (GetPosY() < -46))
+ {
+ TickInVoid(a_Chunk);
+ }
+ else { m_TicksSinceLastVoidDamage = 0; }
}
@@ -803,6 +809,23 @@ void cEntity::TickBurning(cChunk & a_Chunk)
+void cEntity::TickInVoid(cChunk & a_Chunk)
+{
+ if (m_TicksSinceLastVoidDamage == 20)
+ {
+ TakeDamage(dtInVoid, NULL, 2, 0);
+ m_TicksSinceLastVoidDamage = 0;
+ }
+ else
+ {
+ m_TicksSinceLastVoidDamage++;
+ }
+}
+
+
+
+
+
/// Called when the entity starts burning
void cEntity::OnStartedBurning(void)
{
diff --git a/source/Entities/Entity.h b/source/Entities/Entity.h
index b4777d249..df671a564 100644
--- a/source/Entities/Entity.h
+++ b/source/Entities/Entity.h
@@ -255,6 +255,9 @@ public:
/// Updates the state related to this entity being on fire
virtual void TickBurning(cChunk & a_Chunk);
+
+ /// Handles when the entity is in the void
+ virtual void TickInVoid(cChunk & a_Chunk);
/// Called when the entity starts burning
virtual void OnStartedBurning(void);
@@ -377,6 +380,9 @@ protected:
/// Time, in ticks, until the entity extinguishes its fire
int m_TicksLeftBurning;
+
+ /// Time, in ticks, since the last damage dealt by the void. Reset to zero when moving out of the void.
+ int m_TicksSinceLastVoidDamage;
virtual void Destroyed(void) {} // Called after the entity has been destroyed