summaryrefslogtreecommitdiffstats
path: root/src/Entities/ArrowEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-01 23:39:37 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-01 23:39:37 +0200
commit284c1c0514168e30338f2ad372b7e7f185dba0c4 (patch)
tree66e9ef12dda74a3c5e48b0ce8aa96427e903ff40 /src/Entities/ArrowEntity.cpp
parentImplemented Vector3<>::Floor() (diff)
downloadcuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar.gz
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar.bz2
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar.lz
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar.xz
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.tar.zst
cuberite-284c1c0514168e30338f2ad372b7e7f185dba0c4.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/ArrowEntity.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 2d6683f0a..7e96a666d 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -69,14 +69,18 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
Vector3d Hit = a_HitPos;
- Vector3d SinkMovement = GetSpeed() / 800;
- SinkMovement.Clamp(0.001, 0.001, 0.001, 0.05, 0.05, 0.05);
+ 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
super::OnHitSolidBlock(Hit, a_HitFace);
- Hit.Floor();
+ Vector3i BlockHit = Hit.Floor();
- int X = Hit.x, Y = Hit.y, Z = Hit.z;
+ int X = BlockHit.x, Y = BlockHit.y, Z = BlockHit.z;
m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound