summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-04-10 16:57:16 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-04-12 23:35:07 +0200
commita999c5d845bd759c6d83b356c7b39e67473dc452 (patch)
treec8da72f5192293648f30b3228e7563fa7c79d13e /src/Entities
parentAdd animations for shield/item block & break (diff)
downloadcuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar.gz
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar.bz2
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar.lz
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar.xz
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.tar.zst
cuberite-a999c5d845bd759c6d83b356c7b39e67473dc452.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Player.cpp33
-rw-r--r--src/Entities/Player.h15
2 files changed, 30 insertions, 18 deletions
diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp
index 3b005d8eb..1bfeea6e2 100644
--- a/src/Entities/Player.cpp
+++ b/src/Entities/Player.cpp
@@ -123,6 +123,7 @@ cPlayer::cPlayer(const std::shared_ptr<cClientHandle> & a_Client) :
m_IsFlightCapable(false),
m_IsFlying(false),
m_IsFrozen(false),
+ m_IsLeftHanded(false),
m_IsTeleporting(false),
m_IsVisible(true),
m_EatingFinishTick(-1),
@@ -132,8 +133,7 @@ cPlayer::cPlayer(const std::shared_ptr<cClientHandle> & a_Client) :
m_FloaterID(cEntity::INVALID_ID),
m_Team(nullptr),
m_TicksUntilNextSave(PLAYER_INVENTORY_SAVE_INTERVAL),
- m_SkinParts(0),
- m_MainHand(mhRight)
+ m_SkinParts(0)
{
ASSERT(GetName().length() <= 16); // Otherwise this player could crash many clients...
@@ -449,6 +449,15 @@ bool cPlayer::IsInBed(void) const
+bool cPlayer::IsLeftHanded() const
+{
+ return m_IsLeftHanded;
+}
+
+
+
+
+
bool cPlayer::IsStanding() const
{
return std::holds_alternative<BodyStanceStanding>(m_BodyStance);
@@ -692,6 +701,16 @@ void cPlayer::SetFlying(const bool a_ShouldFly)
+void cPlayer::SetLeftHanded(const bool a_IsLeftHanded)
+{
+ m_IsLeftHanded = a_IsLeftHanded;
+ m_World->BroadcastEntityMetadata(*this);
+}
+
+
+
+
+
void cPlayer::SetSprint(const bool a_ShouldSprint)
{
if (a_ShouldSprint && IsStanding())
@@ -2544,16 +2563,6 @@ void cPlayer::SetSkinParts(int a_Parts)
-void cPlayer::SetMainHand(eMainHand a_Hand)
-{
- m_MainHand = a_Hand;
- m_World->BroadcastEntityMetadata(*this, m_ClientHandle.get());
-}
-
-
-
-
-
void cPlayer::AttachTo(cEntity * a_AttachTo)
{
// Different attach, if this is a spectator
diff --git a/src/Entities/Player.h b/src/Entities/Player.h
index 8969099a1..7c8922dbf 100644
--- a/src/Entities/Player.h
+++ b/src/Entities/Player.h
@@ -376,6 +376,9 @@ public:
/** Returns true if a player is sleeping in a bed. */
bool IsInBed(void) const;
+ /** Returns true if the player's left hand is dominant. */
+ bool IsLeftHanded() const;
+
/** Returns true if the player has thrown out a floater */
bool IsFishing(void) const { return m_IsFishing; }
@@ -491,6 +494,9 @@ public:
/** Starts or stops flying, broadcasting the state change. */
void SetFlying(bool a_ShouldFly);
+ /** Sets the dominant hand of the player. */
+ void SetLeftHanded(bool a_IsLeftHanded);
+
/** Starts or stops sprinting, if our current body stance permits, broadcasting the state change. */
void SetSprint(bool a_ShouldSprint);
@@ -557,9 +563,6 @@ public:
int GetSkinParts(void) const { return m_SkinParts; }
void SetSkinParts(int a_Parts);
- eMainHand GetMainHand(void) const { return m_MainHand; }
- void SetMainHand(eMainHand a_Hand);
-
// tolua_end
/** Calls the block placement hooks and places the blocks in the world.
@@ -715,6 +718,9 @@ private:
/** If true, we are locking m_Position to m_FrozenPosition. */
bool m_IsFrozen;
+ /** Whether the player is left-handed, or right-handed. */
+ bool m_IsLeftHanded;
+
/** Was the player frozen manually by a plugin or automatically by the server? */
bool m_IsManuallyFrozen;
@@ -749,9 +755,6 @@ private:
/** Displayed skin part bit mask */
int m_SkinParts;
- /** The main hand of the player */
- eMainHand m_MainHand;
-
/** List on known recipes as Ids */
std::set<UInt32> m_KnownRecipes;