summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 15:01:47 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 15:01:47 +0100
commite3b9cdebc9c07a548c4aa219d53cf53c2c111b48 (patch)
tree690dc920b494db2ece6f3683a071d7ffe2c7ce8b /src
parentUncommented pickup spawner code (diff)
downloadcuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar.gz
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar.bz2
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar.lz
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar.xz
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.tar.zst
cuberite-e3b9cdebc9c07a548c4aa219d53cf53c2c111b48.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp53
1 files changed, 28 insertions, 25 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index 53e5b956b..4511391ff 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1756,39 +1756,42 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
Vector3d EntityPos = a_Entity->GetPosition();
cBoundingBox bbEntity(EntityPos, a_Entity->GetWidth() / 2, a_Entity->GetHeight());
- if (m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
+ if (!m_bbTNT.IsInside(bbEntity)) // IsInside actually acts like DoesSurround
{
- Vector3d AbsoluteEntityPos(abs(EntityPos.x), abs(EntityPos.y), abs(EntityPos.z));
- Vector3d MaxExplosionBoundary(m_ExplosionSizeSq, m_ExplosionSizeSq, m_ExplosionSizeSq);
+ return false;
+ }
+
+ Vector3d AbsoluteEntityPos(abs(EntityPos.x), abs(EntityPos.y), abs(EntityPos.z));
+ Vector3d MaxExplosionBoundary(m_ExplosionSizeSq, m_ExplosionSizeSq, m_ExplosionSizeSq);
- // Work out how far we are from the edge of the TNT's explosive effect
- AbsoluteEntityPos -= m_ExplosionPos;
- AbsoluteEntityPos = MaxExplosionBoundary - AbsoluteEntityPos;
+ // Work out how far we are from the edge of the TNT's explosive effect
+ AbsoluteEntityPos -= m_ExplosionPos;
+ AbsoluteEntityPos = MaxExplosionBoundary - AbsoluteEntityPos;
- double FinalDamage = ((AbsoluteEntityPos.x + AbsoluteEntityPos.y + AbsoluteEntityPos.z) / 3) * m_ExplosionSize;
- FinalDamage = a_Entity->GetMaxHealth() - abs(FinalDamage);
+ double FinalDamage = ((AbsoluteEntityPos.x + AbsoluteEntityPos.y + AbsoluteEntityPos.z) / 3) * m_ExplosionSize;
+ FinalDamage = a_Entity->GetMaxHealth() - abs(FinalDamage);
- // Clip damage values
- if (FinalDamage > a_Entity->GetMaxHealth())
- FinalDamage = a_Entity->GetMaxHealth();
- else if (FinalDamage < 0)
- return false;
+ // Clip damage values
+ if (FinalDamage > a_Entity->GetMaxHealth())
+ FinalDamage = a_Entity->GetMaxHealth();
+ else if (FinalDamage < 0)
+ return false;
- if (!a_Entity->IsTNT()) // Don't apply damage to other TNT entities, they should be invincible
- {
- a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0);
- }
+ if (!a_Entity->IsTNT()) // Don't apply damage to other TNT entities, they should be invincible
+ {
+ a_Entity->TakeDamage(dtExplosion, NULL, (int)FinalDamage, 0);
+ }
- // Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt()
- Vector3d distance_explosion = a_Entity->GetPosition() - m_ExplosionPos;
- if (distance_explosion.SqrLength() < 4096.0)
- {
- distance_explosion.Normalize();
- distance_explosion *= m_ExplosionSizeSq;
+ // Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt()
+ Vector3d distance_explosion = a_Entity->GetPosition() - m_ExplosionPos;
+ if (distance_explosion.SqrLength() < 4096.0)
+ {
+ distance_explosion.Normalize();
+ distance_explosion *= m_ExplosionSizeSq;
- a_Entity->AddSpeed(distance_explosion);
- }
+ a_Entity->AddSpeed(distance_explosion);
}
+
return false;
}