2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
2021-05-05 09:25:10 -04:00
|
|
|
#include "BlockInfo.h"
|
2019-10-16 04:06:34 -04:00
|
|
|
#include "Mixins.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-05 06:27:14 -04:00
|
|
|
class cBlockLadderHandler final :
|
2014-07-14 15:26:36 -04:00
|
|
|
public cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04> >
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cClearMetaOnDrop<cMetaRotator<cBlockHandler, 0x07, 0x02, 0x05, 0x03, 0x04>>;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-09-20 09:50:52 -04:00
|
|
|
using Super::Super;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
/** Returns true if the ladder will be supported by the block through the given blockface. */
|
|
|
|
static bool CanBePlacedOn(const BLOCKTYPE a_BlockType, const eBlockFace a_BlockFace)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2021-05-05 09:25:10 -04:00
|
|
|
if (
|
|
|
|
(a_BlockFace == BLOCK_FACE_NONE) ||
|
|
|
|
(a_BlockFace == BLOCK_FACE_BOTTOM) ||
|
|
|
|
(a_BlockFace == BLOCK_FACE_TOP)
|
|
|
|
)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2021-05-05 09:25:10 -04:00
|
|
|
return false;
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
return cBlockInfo::IsSolid(a_BlockType);
|
2014-07-14 16:57:44 -04:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
private:
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2020-04-21 16:19:22 -04:00
|
|
|
/** Converts the ladder block's meta to the block face of the neighbor to which the ladder is attached. */
|
|
|
|
static eBlockFace MetaDataToBlockFace(NIBBLETYPE a_MetaData)
|
2014-07-14 16:57:44 -04:00
|
|
|
{
|
2013-07-29 07:13:03 -04:00
|
|
|
switch (a_MetaData)
|
|
|
|
{
|
2014-02-04 13:59:05 -05:00
|
|
|
case 0x2: return BLOCK_FACE_ZM;
|
|
|
|
case 0x3: return BLOCK_FACE_ZP;
|
|
|
|
case 0x4: return BLOCK_FACE_XM;
|
|
|
|
case 0x5: return BLOCK_FACE_XP;
|
|
|
|
default: return BLOCK_FACE_ZM;
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2014-07-14 16:57:44 -04:00
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-05-05 09:25:10 -04:00
|
|
|
virtual bool CanBeAt(const cChunk & a_Chunk, const Vector3i a_Position, const NIBBLETYPE a_Meta) const override
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2021-05-05 09:25:10 -04:00
|
|
|
auto Face = MetaDataToBlockFace(a_Meta);
|
|
|
|
auto NeighborRelPos = AddFaceDirection(a_Position, Face, true);
|
|
|
|
BLOCKTYPE NeighborBlockType;
|
|
|
|
a_Chunk.UnboundedRelGetBlockType(NeighborRelPos, NeighborBlockType);
|
|
|
|
return CanBePlacedOn(NeighborBlockType, Face);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2019-10-16 04:06:34 -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 0;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|