summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLO1ZB <franzdervierte@web.de>2015-07-14 20:30:30 +0200
committerLO1ZB <franzdervierte@web.de>2015-07-14 20:30:30 +0200
commit405458d5e291cb6b755755ae5788795f745d70c3 (patch)
tree3dc4fb4d371557d99959a8f6c32826443f40163b
parentMerge pull request #2351 from SamJBarney/TorchStairFix (diff)
downloadcuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar.gz
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar.bz2
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar.lz
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar.xz
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.tar.zst
cuberite-405458d5e291cb6b755755ae5788795f745d70c3.zip
-rw-r--r--src/Entities/Player.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 97e2eca3a..3e1e2b7ea 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -16,6 +16,7 @@
#include "../Items/ItemHandler.h"
#include "../Vector3.h"
#include "../FastRandom.h"
+#include <cmath>
#include "../WorldStorage/StatSerializer.h"
#include "../CompositeChat.h"
@@ -2178,20 +2179,18 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
return;
}
- // Process exhaustion every two ticks as that is how frequently m_LastPos is updated
- // Otherwise, we apply exhaustion for a 'movement' every tick, one of which is an already processed value
- if (GetWorld()->GetWorldAge() % 2 != 0)
- {
- return;
- }
-
// Calculate the distance travelled, update the last pos:
- Vector3d Movement(GetPosition() - m_LastPos);
- Movement.y = 0; // Only take XZ movement into account
+ double SpeedX = m_Speed.x;
+ double SpeedZ = m_Speed.z;
+ double BaseExhaustion(sqrt((SpeedX * SpeedX) + (SpeedZ * SpeedZ)));
// Apply the exhaustion based on distance travelled:
- double BaseExhaustion = Movement.Length();
- if (IsSprinting())
+ if (IsFlying() || IsClimbing())
+ {
+ // Apply no exhaustion when flying or climbing.
+ BaseExhaustion = 0;
+ }
+ else if (IsSprinting())
{
// 0.1 pt per meter sprinted
BaseExhaustion = BaseExhaustion * 0.1;