summaryrefslogtreecommitdiffstats
path: root/src/Entities/Pickup.cpp
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2017-09-02 09:45:06 +0200
committerAlexander Harkness <me@bearbin.net>2017-09-02 09:50:23 +0200
commit49c443896dcac8c4eaf08c4024e8bd2366ad899a (patch)
treeb1ec46cab2b4e5731860c7136f1bbfca6fe9d458 /src/Entities/Pickup.cpp
parentSetSwimState now takes into account head height (diff)
downloadcuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.gz
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.bz2
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.lz
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.xz
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.tar.zst
cuberite-49c443896dcac8c4eaf08c4024e8bd2366ad899a.zip
Diffstat (limited to 'src/Entities/Pickup.cpp')
-rw-r--r--src/Entities/Pickup.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp
index fcae586f6..0c6c8feab 100644
--- a/src/Entities/Pickup.cpp
+++ b/src/Entities/Pickup.cpp
@@ -17,7 +17,8 @@
-class cPickupCombiningCallback
+class cPickupCombiningCallback :
+ public cEntityCallback
{
public:
cPickupCombiningCallback(Vector3d a_Position, cPickup * a_Pickup) :
@@ -27,21 +28,21 @@ public:
{
}
- bool operator () (cEntity & a_Entity)
+ virtual bool Item(cEntity * a_Entity) override
{
- ASSERT(a_Entity.IsTicking());
- if (!a_Entity.IsPickup() || (a_Entity.GetUniqueID() <= m_Pickup->GetUniqueID()) || !a_Entity.IsOnGround())
+ ASSERT(a_Entity->IsTicking());
+ if (!a_Entity->IsPickup() || (a_Entity->GetUniqueID() <= m_Pickup->GetUniqueID()) || !a_Entity->IsOnGround())
{
return false;
}
- Vector3d EntityPos = a_Entity.GetPosition();
+ Vector3d EntityPos = a_Entity->GetPosition();
double Distance = (EntityPos - m_Position).Length();
- auto & OtherPickup = static_cast<cPickup &>(a_Entity);
- cItem & Item = OtherPickup.GetItem();
- if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()) && OtherPickup.CanCombine())
+ cPickup * OtherPickup = static_cast<cPickup *>(a_Entity);
+ cItem & Item = OtherPickup->GetItem();
+ if ((Distance < 1.2) && Item.IsEqual(m_Pickup->GetItem()) && OtherPickup->CanCombine())
{
short CombineCount = Item.m_ItemCount;
if ((CombineCount + m_Pickup->GetItem().m_ItemCount) > Item.GetMaxStackSize())
@@ -63,16 +64,16 @@ public:
int DiffX = FloorC(m_Pickup->GetPosX() * 32.0) - FloorC(EntityPos.x * 32.0);
int DiffY = FloorC(m_Pickup->GetPosY() * 32.0) - FloorC(EntityPos.y * 32.0);
int DiffZ = FloorC(m_Pickup->GetPosZ() * 32.0) - FloorC(EntityPos.z * 32.0);
- a_Entity.GetWorld()->BroadcastEntityRelMove(a_Entity, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ));
+ a_Entity->GetWorld()->BroadcastEntityRelMove(*a_Entity, static_cast<char>(DiffX), static_cast<char>(DiffY), static_cast<char>(DiffZ));
/* End of experimental animation */
- a_Entity.Destroy();
+ a_Entity->Destroy();
// Reset the timer
m_Pickup->SetAge(0);
}
else
{
- a_Entity.GetWorld()->BroadcastEntityMetadata(a_Entity);
+ a_Entity->GetWorld()->BroadcastEntityMetadata(*a_Entity);
}
m_FoundMatchingPickup = true;
}