summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-27 21:39:39 +0200
committerMattes D <github@xoft.cz>2014-07-27 21:39:39 +0200
commit0814a977f8a99fb776a73b44bff14b2a6fb11059 (patch)
treeedd7271430e1c0204808b3c12b7735959677b733 /src/Entities
parentNetherClumpGenerator: Fixed generating stuff on halfslabs and fences (diff)
parentDerp. (diff)
downloadcuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.gz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.bz2
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.lz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.xz
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.tar.zst
cuberite-0814a977f8a99fb776a73b44bff14b2a6fb11059.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/Entity.cpp13
-rw-r--r--src/Entities/Player.cpp4
-rw-r--r--src/Entities/Player.h2
3 files changed, 11 insertions, 8 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index db0fd0fd6..6c3d7b40c 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"
@@ -289,11 +290,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
@@ -306,10 +302,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())
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index fcc8eb9a0..afe5965aa 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -1929,14 +1929,14 @@ cPlayer::StringList cPlayer::GetResolvedPermissions()
-void cPlayer::UseEquippedItem(void)
+void cPlayer::UseEquippedItem(int a_Amount)
{
if (IsGameModeCreative()) // No damage in creative
{
return;
}
- if (GetInventory().DamageEquippedItem())
+ if (GetInventory().DamageEquippedItem(a_Amount))
{
m_World->BroadcastSoundEffect("random.break", GetPosX(), GetPosY(), GetPosZ(), 0.5f, (float)(0.75 + ((float)((GetUniqueID() * 23) % 32)) / 64));
}
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 488884602..69149c90b 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -349,7 +349,7 @@ public:
const AString & GetLoadedWorldName() { return m_LoadedWorldName; }
- void UseEquippedItem(void);
+ void UseEquippedItem(int a_Amount = 1);
void SendHealth(void);