summaryrefslogtreecommitdiffstats
path: root/src/Entities/HangingEntity.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2015-03-15 14:30:23 +0100
committerMattes D <github@xoft.cz>2015-03-15 14:30:23 +0100
commit0add3d461782b7a89ff614f78f77cbb37476594d (patch)
tree22f4c7f9023efc0554cc0c2b67235b93b8bd82fb /src/Entities/HangingEntity.cpp
parentMerge pull request #1811 from mc-server/grass (diff)
parentFixed style violations (diff)
downloadcuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.gz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.bz2
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.lz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.xz
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.tar.zst
cuberite-0add3d461782b7a89ff614f78f77cbb37476594d.zip
Diffstat (limited to 'src/Entities/HangingEntity.cpp')
-rw-r--r--src/Entities/HangingEntity.cpp55
1 files changed, 2 insertions, 53 deletions
diff --git a/src/Entities/HangingEntity.cpp b/src/Entities/HangingEntity.cpp
index a6b9c40c8..a37d8702e 100644
--- a/src/Entities/HangingEntity.cpp
+++ b/src/Entities/HangingEntity.cpp
@@ -11,7 +11,7 @@
cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, double a_X, double a_Y, double a_Z) :
cEntity(a_EntityType, a_X, a_Y, a_Z, 0.8, 0.8),
- m_Facing(a_Facing)
+ m_Facing(cHangingEntity::BlockFaceToProtocolFace(a_Facing))
{
SetMaxHealth(1);
SetHealth(1);
@@ -21,60 +21,9 @@ cHangingEntity::cHangingEntity(eEntityType a_EntityType, eBlockFace a_Facing, do
-void cHangingEntity::SetFacing(eBlockFace a_Facing)
-{
- // Y-based faces are not allowed:
- switch (a_Facing)
- {
- case BLOCK_FACE_NONE:
- case BLOCK_FACE_YM:
- case BLOCK_FACE_YP:
- {
- LOGWARNING("%s: Invalid facing: %d. Ignoring.", __FUNCTION__, a_Facing);
- ASSERT(!"Tried to set a bad facing!");
- return;
- }
- default: break;
- }
-
- m_Facing = a_Facing;
-}
-
-
-
-
-
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_Facing)
- {
- case BLOCK_FACE_ZP: Dir = 0; break;
- case BLOCK_FACE_ZM: Dir = 2; break;
- case BLOCK_FACE_XM: Dir = 1; break;
- case BLOCK_FACE_XP: Dir = 3; break;
- default:
- {
- LOGINFO("Invalid facing (%d) in a cHangingEntity at {%d, %d, %d}, adjusting to BLOCK_FACE_XP.",
- m_Facing, (int)GetPosX(), (int)GetPosY(), (int)GetPosZ()
- );
- Dir = 3;
- }
- }
-
- 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);
+ SetYaw(GetProtocolFacing() * 90);
}