diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-02 22:07:34 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-02 22:07:34 +0200 |
commit | 89a26cc786f3673cf7b5a100300d8aa595735cc3 (patch) | |
tree | bb730e4d205d596232ad1941d92c7a2c5a5a0e72 /src/Entities | |
parent | Vector clamping fixes (diff) | |
download | cuberite-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.cpp | 16 | ||||
-rw-r--r-- | src/Entities/ArrowEntity.h | 6 |
2 files changed, 14 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(); diff --git a/src/Entities/ArrowEntity.h b/src/Entities/ArrowEntity.h index 1fe3032ee..99b7bae31 100644 --- a/src/Entities/ArrowEntity.h +++ b/src/Entities/ArrowEntity.h @@ -58,8 +58,14 @@ public: /// Sets the IsCritical flag void SetIsCritical(bool a_IsCritical) { m_IsCritical = a_IsCritical; } + + /** Gets the block arrow is in */ + Vector3i GetBlockHit(void) const { return m_HitBlockPos; } // tolua_end + + /** Sets the block arrow is in */ + void SetBlockHit(const Vector3i & a_BlockHit) { m_HitBlockPos = a_BlockHit; } protected: |