diff options
author | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-16 18:20:28 +0100 |
---|---|---|
committer | faketruth <faketruth@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-16 18:20:28 +0100 |
commit | 008addf5d746b2d158f9116e4f6302861b42852f (patch) | |
tree | d569fe2253917ca3dc979c1b5b51d534aa4a538e /source/cClientHandle.cpp | |
parent | Chunks are now marked as saved (diff) | |
download | cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.gz cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.bz2 cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.lz cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.xz cuberite-008addf5d746b2d158f9116e4f6302861b42852f.tar.zst cuberite-008addf5d746b2d158f9116e4f6302861b42852f.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cClientHandle.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp index a28d8a56c..c8f8e82ed 100644 --- a/source/cClientHandle.cpp +++ b/source/cClientHandle.cpp @@ -1532,13 +1532,27 @@ void cClientHandle::HandleUseEntity(cPacket_UseEntity * a_Packet) {
return;
}
- cWorld * World = m_Player->GetWorld();
- cEntity * Entity = World->GetEntity(a_Packet->m_TargetID);
- if ((Entity != NULL) && Entity->IsA("cPawn"))
+
+ class cDamageEntity : public cEntityCallback
{
- cPawn * Pawn = (cPawn *)Entity;
- Pawn->TakeDamage(1, m_Player);
- }
+ virtual bool Item(cEntity * a_Entity) override
+ {
+ if( a_Entity->IsA("cPawn") )
+ {
+ reinterpret_cast< cPawn* >( a_Entity )->TakeDamage(Damage, Instigator );
+ }
+ return true;
+ }
+ public:
+ int Damage;
+ cEntity * Instigator;
+ } Callback;
+
+ Callback.Damage = 1; // TODO: Find proper damage from current item equipped
+ Callback.Instigator = m_Player;
+
+ cWorld * World = m_Player->GetWorld();
+ World->DoWithEntity( a_Packet->m_TargetID, Callback );
}
|