summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNate <nate@natedpalm.com>2021-04-06 18:16:31 +0200
committerGitHub <noreply@github.com>2021-04-06 18:16:31 +0200
commit8efe55c62c6737f3a22bbfce867b5a0aa942600f (patch)
tree00edbb5611196eb0c95eb0ab4e4961071ee1da4d
parentBasic elytra flight (#5124) (diff)
downloadcuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar.gz
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar.bz2
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar.lz
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar.xz
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.tar.zst
cuberite-8efe55c62c6737f3a22bbfce867b5a0aa942600f.zip
-rw-r--r--CONTRIBUTORS1
-rw-r--r--src/Entities/SplashPotionEntity.cpp15
2 files changed, 7 insertions, 9 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index f5ee91b89..f8fa2fac5 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -71,6 +71,7 @@ theophriene
tigerw (Tiger Wang)
tonibm19
TooAngel
+tympaniplayer(Nate Palmer)
UltraCoderRU
Warmist
WebFreak001
diff --git a/src/Entities/SplashPotionEntity.cpp b/src/Entities/SplashPotionEntity.cpp
index 35d79e6cd..ce081aed1 100644
--- a/src/Entities/SplashPotionEntity.cpp
+++ b/src/Entities/SplashPotionEntity.cpp
@@ -57,7 +57,11 @@ void cSplashPotionEntity::OnHitEntity(cEntity & a_EntityHit, Vector3d a_HitPos)
void cSplashPotionEntity::Splash(Vector3d a_HitPos)
{
- m_World->ForEachEntity([=](cEntity & a_Entity)
+ double XZCalculation = 8.25/2;
+ double YCalculation = 4.25/2;
+ cBoundingBox SplashDistanceBox = cBoundingBox(a_HitPos.x - XZCalculation, a_HitPos.x + XZCalculation, a_HitPos.y - YCalculation, a_HitPos.y + YCalculation, a_HitPos.z - XZCalculation, a_HitPos.z + XZCalculation);
+
+ m_World->ForEachEntityInBox(SplashDistanceBox, [=](cEntity & a_Entity)
{
if (!a_Entity.IsPawn())
{
@@ -65,15 +69,8 @@ void cSplashPotionEntity::Splash(Vector3d a_HitPos)
return false;
}
- double SplashDistance = (a_Entity.GetPosition() - a_HitPos).Length();
- if (SplashDistance >= 20)
- {
- // Too far away
- return false;
- }
-
// y = -0.25x + 1, where x is the distance from the player. Approximation for potion splash.
- // TODO: better equation
+ double SplashDistance = (a_Entity.GetPosition() - a_HitPos).Length();
double Reduction = -0.25 * SplashDistance + 1.0;
Reduction = std::max(Reduction, 0.0);