summaryrefslogtreecommitdiffstats
path: root/src/Entities/FireworkEntity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-10-21 21:25:52 +0200
committerMattes D <github@xoft.cz>2014-10-21 21:25:52 +0200
commit0c0c762412922b784aaf154b51a8d5d547d3f86f (patch)
tree9e4b70bec26c126ff874e74bf1546df58e1513f1 /src/Entities/FireworkEntity.cpp
parentMerged branch 'master' of git://github.com/sriehl/MCServer (diff)
downloadcuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar.gz
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar.bz2
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar.lz
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar.xz
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.tar.zst
cuberite-0c0c762412922b784aaf154b51a8d5d547d3f86f.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/FireworkEntity.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Entities/FireworkEntity.cpp b/src/Entities/FireworkEntity.cpp
index 403a53c84..68d02640a 100644
--- a/src/Entities/FireworkEntity.cpp
+++ b/src/Entities/FireworkEntity.cpp
@@ -10,7 +10,7 @@
cFireworkEntity::cFireworkEntity(cEntity * a_Creator, double a_X, double a_Y, double a_Z, const cItem & a_Item) :
super(pkFirework, a_Creator, a_X, a_Y, a_Z, 0.25, 0.25),
- m_ExplodeTimer(0),
+ m_TicksToExplosion(a_Item.m_FireworkItem.m_FlightTimeInTicks),
m_FireworkItem(a_Item)
{
}
@@ -27,7 +27,9 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
if ((PosY < 0) || (PosY >= cChunkDef::Height))
{
- goto setspeed;
+ AddSpeedY(1);
+ AddPosition(GetSpeed() * (a_Dt / 1000));
+ return;
}
if (m_IsInGround)
@@ -50,7 +52,6 @@ void cFireworkEntity::HandlePhysics(float a_Dt, cChunk & a_Chunk)
}
}
-setspeed:
AddSpeedY(1);
AddPosition(GetSpeed() * (a_Dt / 1000));
}
@@ -63,11 +64,13 @@ void cFireworkEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
- if (m_ExplodeTimer == m_FireworkItem.m_FireworkItem.m_FlightTimeInTicks)
+ if (m_TicksToExplosion <= 0)
{
+ // TODO: Notify the plugins
m_World->BroadcastEntityStatus(*this, esFireworkExploding);
Destroy();
+ return;
}
- m_ExplodeTimer++;
+ m_TicksToExplosion -= 1;
}