diff options
author | changyong guo <guo1487@163.com> | 2018-07-23 11:24:00 +0200 |
---|---|---|
committer | peterbell10 <peterbell10@live.co.uk> | 2018-07-23 11:24:00 +0200 |
commit | 01e72ddb6567531b16f92af2564b853878b6ef65 (patch) | |
tree | b91403cec84e0b405448d8fadbc2c39f2270ab47 /src/ChunkMap.cpp | |
parent | Keep players in gmNotSet (#4248) (diff) | |
download | cuberite-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.cpp | 19 |
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; } |