summaryrefslogtreecommitdiffstats
path: root/src/Entities/TNTEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-12 20:57:44 +0200
committerGitHub <noreply@github.com>2020-09-12 20:57:44 +0200
commit93adbdce9a769b42baeb70f9ead5c7c6a35834b5 (patch)
treee0116770113a78af0d2d1c4d44a3878f551f0703 /src/Entities/TNTEntity.cpp
parentfixed missing include for FreeBSD. (#4852) (diff)
downloadcuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.gz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.bz2
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.lz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.xz
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.tar.zst
cuberite-93adbdce9a769b42baeb70f9ead5c7c6a35834b5.zip
Diffstat (limited to 'src/Entities/TNTEntity.cpp')
-rw-r--r--src/Entities/TNTEntity.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index aaf3261b4..6aea6e228 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -8,7 +8,7 @@
-cTNTEntity::cTNTEntity(Vector3d a_Pos, int a_FuseTicks) :
+cTNTEntity::cTNTEntity(Vector3d a_Pos, unsigned a_FuseTicks) :
Super(etTNT, a_Pos, 0.98, 0.98),
m_FuseTicks(a_FuseTicks)
{
@@ -33,10 +33,14 @@ void cTNTEntity::SpawnOn(cClientHandle & a_ClientHandle)
void cTNTEntity::Explode(void)
{
- m_FuseTicks = 0;
- Destroy();
FLOGD("BOOM at {0}", GetPosition());
- m_World->DoExplosionAt(4.0, GetPosX(), GetPosY(), GetPosZ(), true, esPrimedTNT, this);
+
+ // Destroy first so the Explodinator doesn't find us (when iterating through entities):
+ Destroy();
+
+ // TODO: provided centred coordinates to all calls to DoExplosionAt, from entities and blocks
+ // This is to ensure maximum efficiency of explosions
+ m_World->DoExplosionAt(4.0, GetPosX(), GetPosY() + GetHeight() / 2, GetPosZ(), true, esPrimedTNT, this);
}
@@ -51,6 +55,7 @@ void cTNTEntity::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
// The base class tick destroyed us
return;
}
+
BroadcastMovementUpdate();
m_FuseTicks -= 1;