summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp32
-rw-r--r--src/Entities/Player.h14
2 files changed, 45 insertions, 1 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index e057c25fe..c2a76342d 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -63,6 +63,8 @@ cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName)
, m_IsSprinting(false)
, m_IsSwimming(false)
, m_IsSubmerged(false)
+ , m_IsFlying(false)
+ , m_CanFly(false)
, m_EatingFinishTick(-1)
, m_IsChargingBow(false)
, m_BowCharge(0)
@@ -751,6 +753,36 @@ void cPlayer::SetSprint(bool a_IsSprinting)
+void cPlayer::SetCanFly(bool a_CanFly)
+{
+ if (a_CanFly == m_CanFly)
+ {
+ return;
+ }
+
+ m_CanFly = a_CanFly;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
+void cPlayer::SetFlying(bool a_IsFlying)
+{
+ if (a_IsFlying == m_IsFlying)
+ {
+ return;
+ }
+
+ m_IsFlying = a_IsFlying;
+ m_ClientHandle->SendPlayerAbilities();
+}
+
+
+
+
+
void cPlayer::DoTakeDamage(TakeDamageInfo & a_TDI)
{
if (a_TDI.DamageType != dtInVoid)
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 44cab7d74..f3ee841e7 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -250,6 +250,8 @@ public:
/// Returns true if the player is currently in the process of eating the currently equipped item
bool IsEating(void) const { return (m_EatingFinishTick >= 0); }
+ /// Returns true if the player is currently flying.
+ bool IsFlying(void) const { return m_IsFlying; }
// tolua_end
/// Starts eating the currently equipped item. Resets the eating timer and sends the proper animation packet
@@ -319,12 +321,20 @@ public:
/// Starts or stops sprinting, sends the max speed update to the client, if needed
void SetSprint(bool a_IsSprinting);
+ /// Flags the player as flying
+ void SetFlying(bool a_IsFlying);
+
+ /// If true the player can fly even when he's not in creative.
+ void SetCanFly(bool a_CanFly);
+
/// Returns whether the player is swimming or not
virtual bool IsSwimming(void) const{ return m_IsSwimming; }
/// Return whether the player is under water or not
virtual bool IsSubmerged(void) const{ return m_IsSubmerged; }
+ /// Returns wheter the player can fly or not.
+ virtual bool CanFly(void) const { return m_CanFly; }
// tolua_end
// cEntity overrides:
@@ -415,10 +425,12 @@ protected:
bool m_IsCrouched;
bool m_IsSprinting;
-
+ bool m_IsFlying;
bool m_IsSwimming;
bool m_IsSubmerged;
+ bool m_CanFly; // If this is true the player can fly. Even if he is not in creative.
+
/// The world tick in which eating will be finished. -1 if not eating
Int64 m_EatingFinishTick;