From 9b9ce6fa3b13cb00e380664a2b51e51ffb209b7d Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 6 Feb 2015 21:40:20 +0100 Subject: Added IsOnGround() to cEntity --- src/Entities/Entity.h | 3 +++ src/Protocol/Protocol18x.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index de9b88dfb..4a819fa4a 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -443,6 +443,9 @@ public: /** Set the invulnerable ticks from the entity */ void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; } + + /** Returns whether the player is on ground or not */ + bool IsOnGround(void) const { return m_bOnGround; } // tolua_end diff --git a/src/Protocol/Protocol18x.cpp b/src/Protocol/Protocol18x.cpp index 7d954a297..9b0f1c37c 100644 --- a/src/Protocol/Protocol18x.cpp +++ b/src/Protocol/Protocol18x.cpp @@ -386,7 +386,7 @@ void cProtocol180::SendEntityLook(const cEntity & a_Entity) Pkt.WriteVarInt(a_Entity.GetUniqueID()); Pkt.WriteByteAngle(a_Entity.GetYaw()); Pkt.WriteByteAngle(a_Entity.GetPitch()); - Pkt.WriteBool(true); // TODO: IsOnGround() on entities + Pkt.WriteBool(a_Entity.IsOnGround()); } @@ -429,7 +429,7 @@ void cProtocol180::SendEntityRelMove(const cEntity & a_Entity, char a_RelX, char Pkt.WriteByte(a_RelX); Pkt.WriteByte(a_RelY); Pkt.WriteByte(a_RelZ); - Pkt.WriteBool(true); // TODO: IsOnGround() on entities + Pkt.WriteBool(a_Entity.IsOnGround()); } @@ -447,7 +447,7 @@ void cProtocol180::SendEntityRelMoveLook(const cEntity & a_Entity, char a_RelX, Pkt.WriteByte(a_RelZ); Pkt.WriteByteAngle(a_Entity.GetYaw()); Pkt.WriteByteAngle(a_Entity.GetPitch()); - Pkt.WriteBool(true); // TODO: IsOnGround() on entities + Pkt.WriteBool(a_Entity.IsOnGround()); } @@ -947,7 +947,7 @@ void cProtocol180::SendPlayerMoveLook(void) Pkt.WriteDouble(Player->GetPosX()); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. - Pkt.WriteDouble(Player->GetStance() + 0.001); + Pkt.WriteDouble(Player->GetPosY() + 0.001); Pkt.WriteDouble(Player->GetPosZ()); Pkt.WriteFloat((float)Player->GetYaw()); @@ -976,7 +976,7 @@ void cProtocol180::SendPlayerSpawn(const cPlayer & a_Player) Pkt.WriteVarInt(a_Player.GetUniqueID()); Pkt.WriteUUID(cMojangAPI::MakeUUIDShort(a_Player.GetUUID())); Pkt.WriteFPInt(a_Player.GetPosX()); - Pkt.WriteFPInt(a_Player.GetPosY()); + Pkt.WriteFPInt(a_Player.GetPosY() + 0.001); // The "+ 0.001" is there because otherwise the player falls through the block they were standing on. Pkt.WriteFPInt(a_Player.GetPosZ()); Pkt.WriteByteAngle(a_Player.GetYaw()); Pkt.WriteByteAngle(a_Player.GetPitch()); @@ -1305,7 +1305,7 @@ void cProtocol180::SendTeleportEntity(const cEntity & a_Entity) Pkt.WriteFPInt(a_Entity.GetPosZ()); Pkt.WriteByteAngle(a_Entity.GetYaw()); Pkt.WriteByteAngle(a_Entity.GetPitch()); - Pkt.WriteBool(true); // TODO: IsOnGrond() on entities + Pkt.WriteBool(a_Entity.IsOnGround()); } -- cgit v1.2.3 From 7813cd20222451f3f1f02b3264bb2d689006f95a Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 6 Feb 2015 21:42:32 +0100 Subject: cPlayer should override IsOnGround() --- src/Entities/Entity.h | 4 ++-- src/Entities/Player.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 4a819fa4a..809e974d2 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -444,8 +444,8 @@ public: /** Set the invulnerable ticks from the entity */ void SetInvulnerableTicks(int a_InvulnerableTicks) { m_InvulnerableTicks = a_InvulnerableTicks; } - /** Returns whether the player is on ground or not */ - bool IsOnGround(void) const { return m_bOnGround; } + /** Returns whether the entity is on ground or not */ + virtual bool IsOnGround(void) const { return m_bOnGround; } // tolua_end diff --git a/src/Entities/Player.h b/src/Entities/Player.h index fa9ac7cad..47bff64f2 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -121,7 +121,7 @@ public: inline void SetStance( const double a_Stance) { m_Stance = a_Stance; } double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export - inline bool IsOnGround(void) const {return m_bTouchGround; } // tolua_export + virtual bool IsOnGround(void) const override {return m_bTouchGround; } inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } -- cgit v1.2.3 From ca591c15a043f66d52d835b316473bdf8ef658d8 Mon Sep 17 00:00:00 2001 From: Howaner Date: Fri, 6 Feb 2015 21:45:29 +0100 Subject: Spacing --- src/Entities/Player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Entities/Player.h b/src/Entities/Player.h index 47bff64f2..7abb1b98a 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -121,7 +121,7 @@ public: inline void SetStance( const double a_Stance) { m_Stance = a_Stance; } double GetEyeHeight(void) const; // tolua_export Vector3d GetEyePosition(void) const; // tolua_export - virtual bool IsOnGround(void) const override {return m_bTouchGround; } + virtual bool IsOnGround(void) const override { return m_bTouchGround; } inline double GetStance(void) const { return GetPosY() + 1.62; } // tolua_export // TODO: Proper stance when crouching etc. inline cInventory & GetInventory(void) { return m_Inventory; } // tolua_export inline const cInventory & GetInventory(void) const { return m_Inventory; } -- cgit v1.2.3