2014-03-16 12:42:23 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../Entities/Player.h"
|
2014-12-13 09:06:55 -05:00
|
|
|
#include "../UI/AnvilWindow.h"
|
2014-03-16 12:42:23 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockAnvilHandler :
|
|
|
|
public cBlockHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cBlockAnvilHandler(BLOCKTYPE a_BlockType)
|
|
|
|
: cBlockHandler(a_BlockType)
|
|
|
|
{
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-03-16 12:42:23 -04:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
|
|
|
{
|
2014-03-16 14:25:00 -04:00
|
|
|
a_Pickups.push_back(cItem(E_BLOCK_ANVIL, 1, a_BlockMeta >> 2));
|
2014-03-16 12:42:23 -04:00
|
|
|
}
|
2014-04-30 18:47:57 -04:00
|
|
|
|
2017-07-31 16:17:52 -04:00
|
|
|
virtual bool OnUse(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override
|
2014-04-30 18:47:57 -04:00
|
|
|
{
|
2014-05-03 17:42:26 -04:00
|
|
|
cWindow * Window = new cAnvilWindow(a_BlockX, a_BlockY, a_BlockZ);
|
2017-07-31 16:17:52 -04:00
|
|
|
a_Player.OpenWindow(*Window);
|
2015-12-01 17:12:44 -05:00
|
|
|
return true;
|
2014-04-30 18:47:57 -04:00
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2014-03-16 12:42:23 -04:00
|
|
|
virtual bool GetPlacementBlockTypeMeta(
|
2017-07-31 16:17:52 -04:00
|
|
|
cChunkInterface & a_ChunkInterface, cPlayer & a_Player,
|
2014-07-17 16:50:58 -04:00
|
|
|
int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace,
|
2014-03-16 12:42:23 -04:00
|
|
|
int a_CursorX, int a_CursorY, int a_CursorZ,
|
|
|
|
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
|
|
|
|
) override
|
|
|
|
{
|
|
|
|
a_BlockType = m_BlockType;
|
2017-07-31 16:17:52 -04:00
|
|
|
NIBBLETYPE Meta = static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage);
|
|
|
|
int Direction = static_cast<int>(floor(a_Player.GetYaw() * 4.0 / 360.0 + 1.5)) & 0x3;
|
2014-08-28 12:57:56 -04:00
|
|
|
|
2014-03-16 12:42:23 -04:00
|
|
|
switch (Direction)
|
|
|
|
{
|
2015-05-19 06:50:59 -04:00
|
|
|
case 0: a_BlockMeta = static_cast<NIBBLETYPE>(0x2 | Meta << 2); break;
|
|
|
|
case 1: a_BlockMeta = static_cast<NIBBLETYPE>(0x3 | Meta << 2); break;
|
|
|
|
case 2: a_BlockMeta = static_cast<NIBBLETYPE>(0x0 | Meta << 2); break;
|
|
|
|
case 3: a_BlockMeta = static_cast<NIBBLETYPE>(0x1 | Meta << 2); break;
|
2014-03-16 12:42:23 -04:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool IsUseable() override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 6;
|
|
|
|
}
|
2014-03-16 12:42:23 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|