summaryrefslogtreecommitdiffstats
path: root/src/Entities/ArrowEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-22 21:44:01 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-06-22 21:44:01 +0200
commit33cc1f2a50d870b7d264ee5479068f8eee3aa458 (patch)
tree1f2d80ea19911c620b5ce17efe502fcb3bc81da0 /src/Entities/ArrowEntity.cpp
parentMerge branch 'master' of https://github.com/mc-server/MCServer (diff)
downloadcuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar.gz
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar.bz2
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar.lz
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar.xz
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.tar.zst
cuberite-33cc1f2a50d870b7d264ee5479068f8eee3aa458.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/ArrowEntity.cpp33
1 files changed, 9 insertions, 24 deletions
diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp
index 8d2569125..db9dc781a 100644
--- a/src/Entities/ArrowEntity.cpp
+++ b/src/Entities/ArrowEntity.cpp
@@ -68,25 +68,16 @@ bool cArrowEntity::CanPickup(const cPlayer & a_Player) const
void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFace)
{
- if (a_HitFace == BLOCK_FACE_NONE) { return; }
-
- super::OnHitSolidBlock(a_HitPos, a_HitFace);
- int a_X = (int)a_HitPos.x, a_Y = (int)a_HitPos.y, a_Z = (int)a_HitPos.z;
-
- switch (a_HitFace)
- {
- case BLOCK_FACE_XM: // Strangely, bounding boxes / block tracers return the actual block for these two directions, so AddFace not needed
- case BLOCK_FACE_YM:
- {
- break;
- }
- default: AddFaceDirection(a_X, a_Y, a_Z, a_HitFace, true);
- }
+ Vector3d Hit = a_HitPos;
+ Hit += GetSpeed() / 700; // Make arrow sink into block a little
+
+ super::OnHitSolidBlock(Hit, a_HitFace);
+ int X = (int)floor(Hit.x), Y = (int)floor(Hit.y), Z = (int)floor(Hit.z);
- m_HitBlockPos = Vector3i(a_X, a_Y, a_Z);
+ m_HitBlockPos = Vector3i(X, Y, Z);
// Broadcast arrow hit sound
- m_World->BroadcastSoundEffect("random.bowhit", (int)GetPosX() * 8, (int)GetPosY() * 8, (int)GetPosZ() * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
+ m_World->BroadcastSoundEffect("random.bowhit", X * 8, Y * 8, Z * 8, 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
@@ -94,13 +85,7 @@ void cArrowEntity::OnHitSolidBlock(const Vector3d & a_HitPos, eBlockFace a_HitFa
void cArrowEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d & a_HitPos)
-{
- if (!a_EntityHit.IsMob() && !a_EntityHit.IsMinecart() && !a_EntityHit.IsPlayer() && !a_EntityHit.IsBoat())
- {
- // Not an entity that interacts with an arrow
- return;
- }
-
+{
int Damage = (int)(GetSpeed().Length() / 20 * m_DamageCoeff + 0.5);
if (m_IsCritical)
{
@@ -165,7 +150,7 @@ void cArrowEntity::Tick(float a_Dt, cChunk & a_Chunk)
if (!m_HasTeleported) // Sent a teleport already, don't do again
{
- if (m_HitGroundTimer > 1000.f) // Send after a second, could be less, but just in case
+ if (m_HitGroundTimer > 500.f) // Send after half a second, could be less, but just in case
{
m_World->BroadcastTeleportEntity(*this);
m_HasTeleported = true;