summaryrefslogtreecommitdiffstats
path: root/src/Entities/Entity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-17 15:32:52 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-17 15:32:52 +0200
commit3dd9649665e88e27298d93fd3c08b76ac5b0befa (patch)
treec5647b99d365190774a2bb9d0628488bafda23f5 /src/Entities/Entity.cpp
parentFixed crash with entities in unloaded chunks (diff)
downloadcuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar.gz
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar.bz2
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar.lz
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar.xz
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.tar.zst
cuberite-3dd9649665e88e27298d93fd3c08b76ac5b0befa.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Entity.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp
index c6dc1fca3..4a6de25b7 100644
--- a/src/Entities/Entity.cpp
+++ b/src/Entities/Entity.cpp
@@ -334,36 +334,21 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
if ((IsMob() || IsPlayer()) && (a_TDI.Attacker != NULL)) // Knockback for only players and mobs
{
- int KnockbackLevel = 0;
- if (a_TDI.Attacker->GetEquippedWeapon().m_ItemType == E_ITEM_BOW)
+ int KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback); // More common enchantment
+ if (KnockbackLevel < 1)
{
+ // We support punch on swords and vice versa! :)
KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchPunch);
}
- else
- {
- KnockbackLevel = a_TDI.Attacker->GetEquippedWeapon().m_Enchantments.GetLevel(cEnchantments::enchKnockback);
- }
- Vector3d additionalSpeed(0, 0, 0);
+ Vector3d AdditionalSpeed(0, 0, 0);
switch (KnockbackLevel)
{
- case 1:
- {
- additionalSpeed.Set(5, .3, 5);
- break;
- }
- case 2:
- {
- additionalSpeed.Set(8, .3, 8);
- break;
- }
- default:
- {
- additionalSpeed.Set(2, .3, 2);
- break;
- }
+ case 1: AdditionalSpeed.Set(5, 0.3, 5); break;
+ case 2: AdditionalSpeed.Set(8, 0.3, 8); break;
+ default: break;
}
- AddSpeed(a_TDI.Knockback * additionalSpeed);
+ AddSpeed(a_TDI.Knockback + AdditionalSpeed);
}
m_World->BroadcastEntityStatus(*this, esGenericHurt);