diff options
author | Mattes D <github@xoft.cz> | 2014-04-26 23:26:59 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-04-26 23:26:59 +0200 |
commit | da931da6037279826a52980f9335e189c370d4d2 (patch) | |
tree | 2935aeea2eab9d1ce7dbf571087d905a4681fae3 /src/Entities | |
parent | Merge pull request #863 from mc-server/chunkysparsing (diff) | |
parent | More small fixes. (diff) | |
download | cuberite-da931da6037279826a52980f9335e189c370d4d2.tar cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.gz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.bz2 cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.lz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.xz cuberite-da931da6037279826a52980f9335e189c370d4d2.tar.zst cuberite-da931da6037279826a52980f9335e189c370d4d2.zip |
Diffstat (limited to 'src/Entities')
-rw-r--r-- | src/Entities/Entity.cpp | 31 | ||||
-rw-r--r-- | src/Entities/Entity.h | 3 | ||||
-rw-r--r-- | src/Entities/FallingBlock.cpp | 4 |
3 files changed, 32 insertions, 6 deletions
diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index d0dd6fb50..7c8e18b51 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -410,11 +410,8 @@ int cEntity::GetRawDamageAgainst(const cEntity & a_Receiver) -int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage) +bool cEntity::ArmorCoversAgainst(eDamageType a_DamageType) { - // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover - - // Filter out damage types that are not protected by armor: // Ref.: http://www.minecraftwiki.net/wiki/Armor#Effects as of 2012_12_20 switch (a_DamageType) { @@ -429,9 +426,33 @@ int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_Dama case dtLightning: case dtPlugin: { - return 0; + return false; + } + + case dtAttack: + case dtArrowAttack: + case dtCactusContact: + case dtLavaContact: + case dtFireContact: + case dtEnderPearl: + case dtExplosion: + { + return true; } } + ASSERT(!"Invalid damage type!"); +} + + + + + +int cEntity::GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_Damage) +{ + // Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover + + // Filter out damage types that are not protected by armor: + if (!ArmorCoversAgainst(a_DamageType)) return 0; // Add up all armor points: // Ref.: http://www.minecraftwiki.net/wiki/Armor#Defense_points as of 2012_12_20 diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 86efc5a98..9b8011b55 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -270,6 +270,9 @@ public: /// Returns the hitpoints that this pawn can deal to a_Receiver using its equipped items virtual int GetRawDamageAgainst(const cEntity & a_Receiver); + /** Returns whether armor will protect against the passed damage type **/ + virtual bool ArmorCoversAgainst(eDamageType a_DamageType); + /// Returns the hitpoints out of a_RawDamage that the currently equipped armor would cover virtual int GetArmorCoverAgainst(const cEntity * a_Attacker, eDamageType a_DamageType, int a_RawDamage); diff --git a/src/Entities/FallingBlock.cpp b/src/Entities/FallingBlock.cpp index a66c7e4ae..bcdac0291 100644 --- a/src/Entities/FallingBlock.cpp +++ b/src/Entities/FallingBlock.cpp @@ -87,7 +87,9 @@ void cFallingBlock::Tick(float a_Dt, cChunk & a_Chunk) AddSpeedY(MilliDt * -9.8f); AddPosition(GetSpeed() * MilliDt); - if ((GetSpeedX() != 0) || (GetSpeedZ() != 0)) + // If not static (One billionth precision) broadcast movement. + static const float epsilon = 0.000000001; + if ((fabs(GetSpeedX()) > epsilon) || (fabs(GetSpeedZ()) > epsilon)) { BroadcastMovementUpdate(); } |