1
0
cuberite-2a/src/Blocks/BlockAnvil.h

92 lines
1.6 KiB
C
Raw Normal View History

2014-03-16 12:42:23 -04:00
#pragma once
#include "BlockHandler.h"
2020-04-10 19:20:51 -04:00
#include "Mixins.h"
2014-03-16 12:42:23 -04:00
#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 final :
2020-04-10 19:20:51 -04:00
public cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>
2014-03-16 12:42:23 -04:00
{
2020-04-13 12:38:06 -04:00
using Super = cYawRotator<cBlockHandler, 0x03, 0x03, 0x00, 0x01, 0x02>;
2014-03-16 12:42:23 -04:00
public:
2020-04-10 19:20:51 -04:00
using Super::Super;
private:
virtual cItems ConvertToPickups(const NIBBLETYPE a_BlockMeta, const cItem * const a_Tool) const override
2014-03-16 12:42:23 -04:00
{
return cItem(m_BlockType, 1, a_BlockMeta >> 2);
2014-03-16 12:42:23 -04:00
}
2014-04-30 18:47:57 -04:00
virtual bool OnUse(
cChunkInterface & a_ChunkInterface,
cWorldInterface & a_WorldInterface,
cPlayer & a_Player,
const Vector3i a_BlockPos,
eBlockFace a_BlockFace,
const Vector3i a_CursorPos
) const override
2014-04-30 18:47:57 -04:00
{
cWindow * Window = new cAnvilWindow(a_BlockPos);
2017-07-31 16:17:52 -04:00
a_Player.OpenWindow(*Window);
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(
cChunkInterface & a_ChunkInterface,
cPlayer & a_Player,
const Vector3i a_PlacedBlockPos,
eBlockFace a_ClickedBlockFace,
const Vector3i a_CursorPos,
2014-03-16 12:42:23 -04:00
BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta
) const override
2014-03-16 12:42:23 -04:00
{
if (!Super::GetPlacementBlockTypeMeta(a_ChunkInterface, a_Player, a_PlacedBlockPos, a_ClickedBlockFace, a_CursorPos, a_BlockType, a_BlockMeta))
2014-03-16 12:42:23 -04:00
{
2020-04-10 19:20:51 -04:00
return false;
2014-03-16 12:42:23 -04:00
}
2020-04-10 19:20:51 -04:00
a_BlockMeta = a_BlockMeta | static_cast<NIBBLETYPE>(a_Player.GetEquippedItem().m_ItemDamage << 2);
2014-03-16 12:42:23 -04:00
return true;
}
virtual bool IsUseable() const override
2014-03-16 12:42:23 -04:00
{
return true;
}
2015-06-30 10:50:15 -04:00
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) const override
2015-06-30 10:50:15 -04:00
{
UNUSED(a_Meta);
return 6;
}
2014-03-16 12:42:23 -04:00
} ;