Modify pickup collection behaviour to correspond to vanilla.
As documented here: https://www.spigotmc.org/threads/item-pickup-radius.337271/#post-3141146
This commit is contained in:
parent
f5ce03d10d
commit
942403de2b
@ -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)
|
void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
|
||||||
{
|
{
|
||||||
double PosX = a_Player.GetPosX();
|
auto BoundingBox = cBoundingBox(a_Player.GetPosition(), a_Player.GetWidth(), a_Player.GetHeight());
|
||||||
double PosY = a_Player.GetPosY();
|
BoundingBox.Expand(1, 0.5, 1);
|
||||||
double PosZ = a_Player.GetPosZ();
|
|
||||||
|
|
||||||
for (auto & Entity : m_Entities)
|
for (auto & Entity : m_Entities)
|
||||||
{
|
{
|
||||||
@ -1635,11 +1634,8 @@ void cChunk::CollectPickupsByPlayer(cPlayer & a_Player)
|
|||||||
{
|
{
|
||||||
continue; // Only pickups and projectiles can be picked up
|
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);
|
if (BoundingBox.IsInside(Entity->GetPosition()))
|
||||||
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
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
LOG("Pickup %d being collected by player \"%s\", distance %f",
|
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);
|
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
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user