summaryrefslogtreecommitdiffstats
path: root/src/Entities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-03-14 00:05:06 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-03-14 00:05:06 +0100
commit3d398baf355fd0dee0e282a73c61fe79f288db8f (patch)
treecc4fc49b1dbcbdf3b0bee969d4b3b5e3ac22ba99 /src/Entities
parentFixed confusion over Item Frame directions (diff)
downloadcuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar.gz
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar.bz2
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar.lz
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar.xz
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.tar.zst
cuberite-3d398baf355fd0dee0e282a73c61fe79f288db8f.zip
Diffstat (limited to 'src/Entities')
-rw-r--r--src/Entities/HangingEntity.cpp2
-rw-r--r--src/Entities/HangingEntity.h13
-rw-r--r--src/Entities/ItemFrame.cpp11
-rw-r--r--src/Entities/ItemFrame.h1
-rw-r--r--src/Entities/Painting.cpp18
-rw-r--r--src/Entities/Painting.h18
6 files changed, 31 insertions, 32 deletions
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index a3d05204a..a37d8702e 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -24,8 +24,6 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, do
void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
{
SetYaw(GetProtocolFacing() * 90);
- a_ClientHandle.SendSpawnObject(*this, 71, GetProtocolFacing(), (Byte)GetYaw(), (Byte)GetPitch());
- a_ClientHandle.SendEntityMetadata(*this);
}
diff --git a/src/Entities/HangingEntity.h b/src/Entities/HangingEntity.h
index de93a73fe..8c9e93622 100644
--- a/src/Entities/HangingEntity.h
+++ b/src/Entities/HangingEntity.h
@@ -41,10 +41,14 @@ public:
m_Facing = a_Facing;
}
-private:
+protected:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
- virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override {}
+ virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override
+ {
+ UNUSED(a_Dt);
+ UNUSED(a_Chunk);
+ }
/** Converts protocol hanging item facing to eBlockFace values */
inline static eBlockFace ProtocolFaceToBlockFace(Byte a_ProtocolFace)
@@ -84,8 +88,9 @@ private:
case BLOCK_FACE_XP: Dir = 3; break;
default:
{
- LOGINFO("Invalid facing (%d) in a cHangingEntity, adjusting to BLOCK_FACE_XP.", a_BlockFace);
- // Uncomment when entities are initialised with their real data, instead of dummy values: ASSERT(!"Tried to convert a bad facing!");
+ // Uncomment when entities are initialised with their real data, instead of dummy values:
+ // LOGINFO("Invalid facing (%d) in a cHangingEntity, adjusting to BLOCK_FACE_XP.", a_BlockFace);
+ // ASSERT(!"Tried to convert a bad facing!");
Dir = cHangingEntity::BlockFaceToProtocolFace(BLOCK_FACE_XP);
}
diff --git a/src/Entities/ItemFrame.cpp b/src/Entities/ItemFrame.cpp
index dfffcd3ed..4e6e38f1f 100644
--- a/src/Entities/ItemFrame.cpp
+++ b/src/Entities/ItemFrame.cpp
@@ -92,3 +92,14 @@ void cItemFrame::GetDrops(cItems & a_Items, cEntity * a_Killer)
+
+void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ super::SpawnOn(a_ClientHandle);
+ a_ClientHandle.SendSpawnObject(*this, 71, GetProtocolFacing(), (Byte)GetYaw(), (Byte)GetPitch());
+ a_ClientHandle.SendEntityMetadata(*this);
+}
+
+
+
+
diff --git a/src/Entities/ItemFrame.h b/src/Entities/ItemFrame.h
index ced8c37af..2444b26a3 100644
--- a/src/Entities/ItemFrame.h
+++ b/src/Entities/ItemFrame.h
@@ -42,6 +42,7 @@ private:
virtual void OnRightClicked(cPlayer & a_Player) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
+ virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
cItem m_Item;
Byte m_ItemRotation;
diff --git a/src/Entities/Painting.cpp b/src/Entities/Painting.cpp
index 6f6277f28..02a8f6ed0 100644
--- a/src/Entities/Painting.cpp
+++ b/src/Entities/Painting.cpp
@@ -10,10 +10,9 @@
-cPainting::cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z)
- : cEntity(etPainting, a_X, a_Y, a_Z, 1, 1),
- m_Name(a_Name),
- m_Direction(a_Direction)
+cPainting::cPainting(const AString & a_Name, eBlockFace a_Direction, double a_X, double a_Y, double a_Z)
+ : cHangingEntity(etPainting, a_Direction, a_X, a_Y, a_Z),
+ m_Name(a_Name)
{
}
@@ -24,6 +23,7 @@ cPainting::cPainting(const AString & a_Name, int a_Direction, double a_X, double
void cPainting::SpawnOn(cClientHandle & a_Client)
{
+ super::SpawnOn(a_Client);
a_Client.SendPaintingSpawn(*this);
}
@@ -31,16 +31,6 @@ void cPainting::SpawnOn(cClientHandle & a_Client)
-void cPainting::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
-{
- UNUSED(a_Dt);
- UNUSED(a_Chunk);
-}
-
-
-
-
-
void cPainting::GetDrops(cItems & a_Items, cEntity * a_Killer)
{
if ((a_Killer != nullptr) && a_Killer->IsPlayer() && !((cPlayer *)a_Killer)->IsGameModeCreative())
diff --git a/src/Entities/Painting.h b/src/Entities/Painting.h
index 6e8a382fc..20968d4f0 100644
--- a/src/Entities/Painting.h
+++ b/src/Entities/Painting.h
@@ -1,7 +1,7 @@
#pragma once
-#include "Entity.h"
+#include "HangingEntity.h"
@@ -9,9 +9,9 @@
// tolua_begin
class cPainting :
- public cEntity
+ public cHangingEntity
{
- typedef cEntity super;
+ typedef cHangingEntity super;
public:
@@ -19,19 +19,14 @@ public:
CLASS_PROTODEF(cPainting)
- cPainting(const AString & a_Name, int a_Direction, double a_X, double a_Y, double a_Z);
+ cPainting(const AString & a_Name, eBlockFace a_Direction, double a_X, double a_Y, double a_Z);
- // tolua_begin
-
- const AString & GetName(void) const { return m_Name; }
- int GetDirection(void) const { return m_Direction; }
-
- // tolua_end
+ /** Returns the protocol name of the painting */
+ const AString & GetName(void) const { return m_Name; } // tolua_export
private:
virtual void SpawnOn(cClientHandle & a_Client) override;
- virtual void Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) override;
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
virtual void KilledBy(TakeDamageInfo & a_TDI) override
{
@@ -40,7 +35,6 @@ private:
}
AString m_Name;
- int m_Direction;
}; // tolua_export