summaryrefslogtreecommitdiffstats
path: root/source/Entities/Entity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2013-09-11 21:19:39 +0200
committerMattes D <github@xoft.cz>2013-09-11 21:19:39 +0200
commit85804d085deaa311a91dc272b0715c0f18771207 (patch)
tree74bff08b3a69a18d6832a7bb3d5660281f600f3e /source/Entities/Entity.cpp
parentMerge pull request #161 from worktycho/master (diff)
parentMore changes [SEE DESC] (diff)
downloadcuberite-85804d085deaa311a91dc272b0715c0f18771207.tar
cuberite-85804d085deaa311a91dc272b0715c0f18771207.tar.gz
cuberite-85804d085deaa311a91dc272b0715c0f18771207.tar.bz2
cuberite-85804d085deaa311a91dc272b0715c0f18771207.tar.lz
cuberite-85804d085deaa311a91dc272b0715c0f18771207.tar.xz
cuberite-85804d085deaa311a91dc272b0715c0f18771207.tar.zst
cuberite-85804d085deaa311a91dc272b0715c0f18771207.zip
Diffstat (limited to 'source/Entities/Entity.cpp')
-rw-r--r--source/Entities/Entity.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/source/Entities/Entity.cpp b/source/Entities/Entity.cpp
index 1a593b3d1..cb6799d33 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)
@@ -505,6 +506,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; }
}
@@ -524,8 +530,15 @@ void cEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((BlockY >= cChunkDef::Height) || (BlockY < 0))
{
// Outside of the world
- // TODO: Current speed should still be added to the entity position
- // Otherwise TNT explosions in the void will still effect the bottommost layers of the world
+
+ cChunk * NextChunk = a_Chunk.GetNeighborChunk(BlockX, BlockZ);
+ // See if we can commit our changes. If not, we will discard them.
+ if (NextChunk != NULL)
+ {
+ SetSpeed(NextSpeed);
+ NextPos += (NextSpeed * a_Dt);
+ SetPosition(NextPos);
+ }
return;
}
@@ -829,6 +842,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)
{