summaryrefslogtreecommitdiffstats
path: root/src/Chunk.cpp
diff options
context:
space:
mode:
authorAlexander Harkness <me@bearbin.net>2020-05-03 01:13:34 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-05-03 12:49:07 +0200
commit942403de2bba7f49919f52e2f8547a9794763d98 (patch)
treef7dcbe2fc5b1f2aa1f083712c1609498dae716ed /src/Chunk.cpp
parentAssert if world is incorrect (diff)
downloadcuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar.gz
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar.bz2
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar.lz
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar.xz
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.tar.zst
cuberite-942403de2bba7f49919f52e2f8547a9794763d98.zip
Diffstat (limited to 'src/Chunk.cpp')
-rw-r--r--src/Chunk.cpp20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index f213dbf69..66c8cf4c3 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -1625,9 +1625,8 @@ void cChunk::SetAreaBiome(int a_MinRelX, int a_MaxRelX, int a_MinRelZ, int a_Max
void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
{
- double PosX = a_Player.GetPosX();
- double PosY = a_Player.GetPosY();
- double PosZ = a_Player.GetPosZ();
+ auto BoundingBox = cBoundingBox(a_Player.GetPosition(), a_Player.GetWidth(), a_Player.GetHeight());
+ BoundingBox.Expand(1, 0.5, 1);
for (auto & Entity : m_Entities)
{
@@ -1635,11 +1634,8 @@ void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
{
continue; // Only pickups and projectiles can be picked up
}
- float DiffX = static_cast<float>(Entity->GetPosX() - PosX);
- float DiffY = static_cast<float>(Entity->GetPosY() - PosY);
- float DiffZ = static_cast<float>(Entity->GetPosZ() - PosZ);
- float SqrDist = DiffX * DiffX + DiffY * DiffY + DiffZ * DiffZ;
- if (SqrDist < 1.5f * 1.5f) // 1.5 block
+
+ if (BoundingBox.IsInside(Entity->GetPosition()))
{
/*
LOG("Pickup %d being collected by player \"%s\", distance %f",
@@ -1656,14 +1652,6 @@ void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
static_cast<cProjectileEntity &>(*Entity).CollectedBy(a_Player);
}
}
- else if (SqrDist < 5 * 5)
- {
- /*
- LOG("Pickup %d close to player \"%s\", but still too far to collect: %f",
- (*itr)->GetUniqueID(), a_Player->GetName().c_str(), SqrDist
- );
- */
- }
}
}