summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-02 22:24:06 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-02 22:24:06 +0100
commitba398c06d78f6e11e7ac322e5ef46df4a91b5776 (patch)
tree4e3103075c4de29744e297c572a252eb79bfb204
parentTNT improvements (diff)
downloadcuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar.gz
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar.bz2
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar.lz
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar.xz
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.tar.zst
cuberite-ba398c06d78f6e11e7ac322e5ef46df4a91b5776.zip
Diffstat (limited to '')
-rw-r--r--src/ChunkMap.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index e23a29a11..53e5b956b 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1719,7 +1719,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
cBlockHandler * Handler = BlockHandler(Block);
Handler->ConvertToPickups(Drops, area.GetBlockMeta(bx + x, by + y, bz + z)); // Stone becomes cobblestone, coal ore becomes coal, etc.
- //m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
+ m_World->SpawnItemPickups(Drops, bx + x, by + y, bz + z);
}
area.SetBlockType(bx + x, by + y, bz + z, E_BLOCK_AIR);
a_BlocksAffected.push_back(Vector3i(bx + x, by + y, bz + z));
@@ -1747,7 +1747,7 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
{
if (a_Entity->IsPickup())
{
- if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible
+ if (((cPickup *)a_Entity)->GetAge() < 20) // If pickup age is smaller than one second, it is invincible (so we don't kill pickups that were just spawned)
{
return false;
}
@@ -1761,21 +1761,25 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
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;
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;
- if (!a_Entity->IsTNT())
+ 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)
{