summaryrefslogtreecommitdiffstats
path: root/src/Entities/HangingEntity.cpp
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-03-18 21:49:08 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-03-18 21:49:08 +0100
commitb8fe024f9de9988b8aa2fc86a1d52b8dbf5712df (patch)
tree93afcc6d60f697fe59a12b4e67a780a0c7a3907e /src/Entities/HangingEntity.cpp
parentAdded levels of shrapnel (diff)
parentFixed chunkmap tree block replacing. (diff)
downloadcuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar.gz
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar.bz2
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar.lz
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar.xz
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.tar.zst
cuberite-b8fe024f9de9988b8aa2fc86a1d52b8dbf5712df.zip
Diffstat (limited to 'src/Entities/HangingEntity.cpp')
-rw-r--r--src/Entities/HangingEntity.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
new file mode 100644
index 000000000..41ac86268
--- /dev/null
+++ b/src/Entities/HangingEntity.cpp
@@ -0,0 +1,53 @@
+
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "HangingEntity.h"
+#include "ClientHandle.h"
+#include "Player.h"
+
+
+
+
+
+cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
+ : cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8)
+ , m_BlockFace(a_BlockFace)
+{
+ SetMaxHealth(1);
+ SetHealth(1);
+}
+
+
+
+
+
+void cHangingEntity::SpawnOn(cClientHandle & a_ClientHandle)
+{
+ int Dir = 0;
+
+ // The client uses different values for item frame directions and block faces. Our constants are for the block faces, so we convert them here to item frame faces
+ switch (m_BlockFace)
+ {
+ case BLOCK_FACE_ZP: break; // Initialised to zero
+ case BLOCK_FACE_ZM: Dir = 2; break;
+ case BLOCK_FACE_XM: Dir = 1; break;
+ case BLOCK_FACE_XP: Dir = 3; break;
+ default: ASSERT(!"Unhandled block face when trying to spawn item frame!"); return;
+ }
+
+ if ((Dir == 0) || (Dir == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
+ {
+ SetYaw((Dir * 90) - 180);
+ }
+ else
+ {
+ SetYaw(Dir * 90);
+ }
+
+ a_ClientHandle.SendSpawnObject(*this, 71, Dir, (Byte)GetYaw(), (Byte)GetPitch());
+ a_ClientHandle.SendEntityMetadata(*this);
+}
+
+
+
+