Simplified the anvil placement code.
This commit is contained in:
parent
7cc322332b
commit
aa7552309a
@ -18,11 +18,13 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
||||||
{
|
{
|
||||||
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
|
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool GetPlacementBlockTypeMeta(
|
virtual bool GetPlacementBlockTypeMeta(
|
||||||
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
cChunkInterface & a_ChunkInterface, cPlayer * a_Player,
|
||||||
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
||||||
@ -31,27 +33,23 @@ public:
|
|||||||
) override
|
) override
|
||||||
{
|
{
|
||||||
a_BlockType = m_BlockType;
|
a_BlockType = m_BlockType;
|
||||||
|
NIBBLETYPE HighBits = a_BlockMeta & 0x0c; // Only highest two bits are preserved
|
||||||
int Direction = (int)floor(a_Player->GetYaw() * 4.0 / 360.0 + 0.5) & 0x3;
|
int Direction = (int)floor(a_Player->GetYaw() * 4.0 / 360.0 + 1.5) & 0x3;
|
||||||
NIBBLETYPE RawMeta = a_BlockMeta >> 2;
|
|
||||||
|
|
||||||
Direction++;
|
|
||||||
Direction %= 4;
|
|
||||||
switch (Direction)
|
switch (Direction)
|
||||||
{
|
{
|
||||||
case 0: a_BlockMeta = 0x2 | (RawMeta << 2); break;
|
case 0: a_BlockMeta = 0x2 | HighBits; break;
|
||||||
case 1: a_BlockMeta = 0x3 | (RawMeta << 2); break;
|
case 1: a_BlockMeta = 0x3 | HighBits; break;
|
||||||
case 2: a_BlockMeta = 0x0 | (RawMeta << 2); break;
|
case 2: a_BlockMeta = 0x0 | HighBits; break;
|
||||||
case 3: a_BlockMeta = 0x1 | (RawMeta << 2); break;
|
case 3: a_BlockMeta = 0x1 | HighBits; break;
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual bool IsUseable() override
|
virtual bool IsUseable() override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user