summaryrefslogtreecommitdiffstats
path: root/src/ChunkMap.cpp
diff options
context:
space:
mode:
authorchangyong guo <guo1487@163.com>2018-07-23 11:24:00 +0200
committerpeterbell10 <peterbell10@live.co.uk>2018-07-23 11:24:00 +0200
commit01e72ddb6567531b16f92af2564b853878b6ef65 (patch)
treeb91403cec84e0b405448d8fadbc2c39f2270ab47 /src/ChunkMap.cpp
parentKeep players in gmNotSet (#4248) (diff)
downloadcuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar.gz
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar.bz2
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar.lz
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar.xz
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.tar.zst
cuberite-01e72ddb6567531b16f92af2564b853878b6ef65.zip
Diffstat (limited to 'src/ChunkMap.cpp')
-rw-r--r--src/ChunkMap.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index d970956f3..770d34b5a 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -1814,10 +1814,21 @@ void cChunkMap::DoExplosionAt(double a_ExplosionSize, double a_BlockX, double a_
a_Entity.TakeDamage(dtExplosion, nullptr, static_cast<int>((1 / DistanceFromExplosion.Length()) * 6 * ExplosionSizeInt), 0);
}
- // Apply force to entities around the explosion - code modified from World.cpp DoExplosionAt()
- DistanceFromExplosion.Normalize();
- DistanceFromExplosion *= ExplosionSizeInt * ExplosionSizeInt;
- a_Entity.AddSpeed(DistanceFromExplosion);
+ double Length = DistanceFromExplosion.Length();
+ if (Length <= ExplosionSizeInt) // Entity is impacted by explosion
+ {
+ float EntityExposure = a_Entity.GetExplosionExposureRate(ExplosionPos, ExplosionSizeInt);
+
+ // Exposure reduced by armor
+ EntityExposure = EntityExposure * (1.0f - a_Entity.GetEnchantmentBlastKnockbackReduction());
+
+ double Impact = (1 - ((Length / ExplosionSizeInt) / 2)) * EntityExposure;
+
+ DistanceFromExplosion.Normalize();
+ DistanceFromExplosion *= Impact;
+
+ a_Entity.AddSpeed(DistanceFromExplosion);
+ }
return false;
}