summaryrefslogtreecommitdiffstats
path: root/src/Entities/Player.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 19:46:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-07-02 19:46:13 +0200
commitc1ae5513ec9e9cc3aac641b793a77f3ef4c14bda (patch)
tree1624effc95b97caa3778b6311849a1433bc844fa /src/Entities/Player.cpp
parentRedstone simulator is alerted to lever unpowering (diff)
downloadcuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.gz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.bz2
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.lz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.xz
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.tar.zst
cuberite-c1ae5513ec9e9cc3aac641b793a77f3ef4c14bda.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index daf1ef2cc..66791eb7c 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -71,6 +71,7 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_FloaterID(-1)
, m_Team(NULL)
, m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL)
+ , m_bIsTeleporting(false)
{
LOGD("Created a player object for \"%s\" @ \"%s\" at %p, ID %d",
a_PlayerName.c_str(), a_Client->GetIPString().c_str(),
@@ -225,7 +226,7 @@ void cPlayer::Tick(float a_Dt, cChunk & a_Chunk)
SendExperience();
}
- if (GetPosition() != m_LastPos) // Change in position from last tick?
+ if (!GetPosition().EqualsEps(m_LastPos, 0.01)) // Non negligible change in position from last tick?
{
// Apply food exhaustion from movement:
ApplyFoodExhaustionFromMovement();
@@ -970,6 +971,7 @@ void cPlayer::Respawn(void)
// Reset food level:
m_FoodLevel = MAX_FOOD_LEVEL;
m_FoodSaturationLevel = 5;
+ m_FoodExhaustionLevel = 0;
// Reset Experience
m_CurrentXp = 0;
@@ -1226,6 +1228,7 @@ void cPlayer::TeleportToCoords(double a_PosX, double a_PosY, double a_PosZ)
SetPosition(a_PosX, a_PosY, a_PosZ);
m_LastGroundHeight = (float)a_PosY;
m_LastJumpHeight = (float)a_PosY;
+ m_bIsTeleporting = true;
m_World->BroadcastTeleportEntity(*this, GetClientHandle());
m_ClientHandle->SendPlayerMoveLook();
@@ -2079,6 +2082,11 @@ void cPlayer::ApplyFoodExhaustionFromMovement()
{
return;
}
+ if (m_bIsTeleporting)
+ {
+ m_bIsTeleporting = false;
+ return;
+ }
// If riding anything, apply no food exhaustion
if (m_AttachedTo != NULL)