Changed BlockFace type to eBlockFace
This commit is contained in:
parent
9c409fc65c
commit
05789f9e66
@ -9,7 +9,7 @@
|
||||
|
||||
|
||||
|
||||
cItemFrame::cItemFrame(int a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
cItemFrame::cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
: cEntity(etItemFrame, a_X, a_Y, a_Z, 0.8, 0.8),
|
||||
m_BlockFace(a_BlockFace),
|
||||
m_Item(E_BLOCK_AIR),
|
||||
@ -17,15 +17,6 @@ cItemFrame::cItemFrame(int a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
{
|
||||
SetMaxHealth(1);
|
||||
SetHealth(1);
|
||||
|
||||
if ((a_BlockFace == 0) || (a_BlockFace == 2)) // Probably a client bug, but two directions are flipped and contrary to the norm, so we do -180
|
||||
{
|
||||
SetYaw((a_BlockFace * 90) - 180);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetYaw(a_BlockFace * 90);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -34,7 +25,28 @@ cItemFrame::cItemFrame(int a_BlockFace, double a_X, double a_Y, double a_Z)
|
||||
|
||||
void cItemFrame::SpawnOn(cClientHandle & a_ClientHandle)
|
||||
{
|
||||
a_ClientHandle.SendSpawnObject(*this, 71, m_BlockFace, (Byte)GetYaw(), (Byte)GetPitch());
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
@ -91,6 +103,7 @@ void cItemFrame::KilledBy(cEntity * a_Killer)
|
||||
|
||||
SetHealth(GetMaxHealth());
|
||||
m_Item.Clear();
|
||||
m_Rotation = 0;
|
||||
GetWorld()->BroadcastEntityMetadata(*this);
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ public:
|
||||
|
||||
CLASS_PROTODEF(cItemFrame);
|
||||
|
||||
cItemFrame(int a_BlockFace, double a_X, double a_Y, double a_Z);
|
||||
cItemFrame(eBlockFace a_BlockFace, double a_X, double a_Y, double a_Z);
|
||||
|
||||
const cItem & GetItem(void) { return m_Item; }
|
||||
Byte GetRotation(void) const { return m_Rotation; }
|
||||
@ -31,7 +31,7 @@ private:
|
||||
virtual void KilledBy(cEntity * a_Killer) override;
|
||||
virtual void GetDrops(cItems & a_Items, cEntity * a_Killer) override;
|
||||
|
||||
int m_BlockFace;
|
||||
eBlockFace m_BlockFace;
|
||||
cItem m_Item;
|
||||
Byte m_Rotation;
|
||||
|
||||
|
@ -33,19 +33,7 @@ public:
|
||||
|
||||
if (Block == E_BLOCK_AIR)
|
||||
{
|
||||
int Dir = 0;
|
||||
|
||||
// The client uses different values for painting directions and block faces. Our constants are for the block faces, so we convert them here to painting faces
|
||||
switch (a_Dir)
|
||||
{
|
||||
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 spawn item frame!"); return false;
|
||||
}
|
||||
|
||||
cItemFrame * ItemFrame = new cItemFrame(Dir, a_BlockX, a_BlockY, a_BlockZ);
|
||||
cItemFrame * ItemFrame = new cItemFrame(a_Dir, a_BlockX, a_BlockY, a_BlockZ);
|
||||
ItemFrame->Initialize(a_World);
|
||||
|
||||
if (!a_Player->IsGameModeCreative())
|
||||
|
Loading…
Reference in New Issue
Block a user