summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-16 23:22:45 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-16 23:22:45 +0200
commit174906efca7f81655a57fa0a30c1158a16e77117 (patch)
treecdee51f6a2d04239a07f2f8342559e3f1a85f946
parentFixed a bug with buckets (diff)
downloadcuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar.gz
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar.bz2
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar.lz
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar.xz
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.tar.zst
cuberite-174906efca7f81655a57fa0a30c1158a16e77117.zip
-rw-r--r--src/Entities/Player.cpp9
-rw-r--r--src/Entities/Player.h2
2 files changed, 10 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index f131a1829..7b3827f42 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -2141,6 +2141,8 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+
+ // If we have just teleported, apply no exhaustion
if (m_bIsTeleporting)
{
m_bIsTeleporting = false;
@@ -2152,6 +2154,13 @@ 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);
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 8f9b46e0f..b0fa01a7f 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -449,7 +449,7 @@ protected:
double m_FoodSaturationLevel;
/** Count-up to the healing or damaging action, based on m_FoodLevel */
- int m_FoodTickTimer;
+ int m_FoodTickTimer;
/** A "buffer" which adds up hunger before it is substracted from m_FoodSaturationLevel or m_FoodLevel. Each action adds a little */
double m_FoodExhaustionLevel;