diff options
author | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-29 16:27:19 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@hotmail.co.uk> | 2014-07-29 16:27:19 +0200 |
commit | 8811837aea2a33ba5da424087429864f811bf5e5 (patch) | |
tree | baeedba8fb618766cf7d4e1657d2d48c84f45a59 /src/Entities/Entity.cpp | |
parent | Suggestions (diff) | |
parent | DistortedHeightmap: Now generates gravel in deep ocean. (diff) | |
download | cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.gz cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.bz2 cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.lz cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.xz cuberite-8811837aea2a33ba5da424087429864f811bf5e5.tar.zst cuberite-8811837aea2a33ba5da424087429864f811bf5e5.zip |
Diffstat (limited to 'src/Entities/Entity.cpp')
-rw-r--r-- | src/Entities/Entity.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 45c347aeb..261afd89d 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -12,6 +12,7 @@ #include "../Bindings/PluginManager.h" #include "../Tracer.h" #include "Player.h" +#include "Items/ItemHandler.h" @@ -290,11 +291,6 @@ void cEntity::SetPitchFromSpeed(void) bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) { - if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) - { - return false; - } - if (m_Health <= 0) { // Can't take damage if already dead @@ -307,10 +303,17 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI) return false; } + if (cRoot::Get()->GetPluginManager()->CallHookTakeDamage(*this, a_TDI)) + { + return false; + } + if ((a_TDI.Attacker != NULL) && (a_TDI.Attacker->IsPlayer())) { cPlayer * Player = (cPlayer *)a_TDI.Attacker; + Player->GetEquippedItem().GetHandler()->OnEntityAttack(Player, this); + // IsOnGround() only is false if the player is moving downwards // TODO: Better damage increase, and check for enchantments (and use magic critical instead of plain) if (!Player->IsOnGround()) |