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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-05 06:27:14 -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
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-23 11:06:27 -04:00
|
|
|
virtual cItems ConvertToPickups(NIBBLETYPE a_BlockMeta, const cEntity * a_Digger, const cItem * a_Tool) const override
|
2014-03-16 12:42:23 -04:00
|
|
|
{
|
2019-10-16 04:06:34 -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
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-04-21 16:19:22 -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
|
2020-09-20 09:50:52 -04:00
|
|
|
) const override
|
2014-04-30 18:47:57 -04:00
|
|
|
{
|
2020-07-04 17:49:17 -04:00
|
|
|
cWindow * Window = new cAnvilWindow(a_BlockPos);
|
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
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-16 12:42:23 -04:00
|
|
|
virtual bool GetPlacementBlockTypeMeta(
|
2020-04-21 16:19:22 -04:00
|
|
|
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
|
2020-09-20 09:50:52 -04:00
|
|
|
) const override
|
2014-03-16 12:42:23 -04:00
|
|
|
{
|
2020-04-21 16:19:22 -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;
|
|
|
|
}
|
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
virtual bool IsUseable() const override
|
2014-03-16 12:42:23 -04:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-09-20 09:50:52 -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
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|