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

92 lines
1.6 KiB
C
Raw Normal View History

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