summaryrefslogtreecommitdiffstats
path: root/src/Entities/ArrowEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 22:07:34 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 22:07:34 +0200
commit89a26cc786f3673cf7b5a100300d8aa595735cc3 (patch)
treebb730e4d205d596232ad1941d92c7a2c5a5a0e72 /src/Entities/ArrowEntity.cpp
parentVector clamping fixes (diff)
downloadcuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar.gz
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar.bz2
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar.lz
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar.xz
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.tar.zst
cuberite-89a26cc786f3673cf7b5a100300d8aa595735cc3.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/ArrowEntity.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 7e96a666d..c039b0b3c 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -67,15 +67,15 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
-{
+{
+ if (GetSpeed().SqrLength() == 0)
+ {
+ SetSpeed(GetLookVector().NormalizeCopy() * 0.1); // Ensure that no division by zero happens later
+ }
+
Vector3d Hit = a_HitPos;
- Vector3d SinkMovement = GetSpeed() / 800; // Base value for arrow penetration
- SinkMovement = Clamp( // Adjust the movement so that fast arrows don't go through blocks (though in reality they would, in addition to exploding into fragments :P)
- SinkMovement,
- (SinkMovement * 0.001) / SinkMovement.Length(),
- (SinkMovement * 0.05) / SinkMovement.Length()
- );
- Hit += SinkMovement; // Make arrow sink into block a little
+ Vector3d SinkMovement = (GetSpeed() / 800);
+ Hit += (SinkMovement * 0.01) / SinkMovement.Length(); // Make arrow sink into block a centimetre so it lodges (but not to far so it goes black clientside)
super::OnHitSolidBlock(Hit, a_HitFace);
Vector3i BlockHit = Hit.Floor();