2014-07-17 20:19:30 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-07-18 11:04:01 -04:00
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../Entities/Player.h"
|
2014-07-17 20:19:30 -04:00
|
|
|
#include "Chunk.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockWallSignHandler :
|
2014-07-18 11:04:01 -04:00
|
|
|
public cBlockHandler
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
2014-07-18 11:04:01 -04:00
|
|
|
typedef cBlockHandler super;
|
2014-07-18 16:41:48 -04:00
|
|
|
|
2014-07-17 20:19:30 -04:00
|
|
|
public:
|
2014-07-18 16:41:48 -04:00
|
|
|
cBlockWallSignHandler(BLOCKTYPE a_BlockType) :
|
|
|
|
super(a_BlockType)
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-18 11:04:01 -04:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
|
|
|
{
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_SIGN, 1, 0));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-17 20:19:30 -04:00
|
|
|
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override
|
|
|
|
{
|
|
|
|
int BlockX = (a_Chunk.GetPosX() * cChunkDef::Width) + a_RelX;
|
|
|
|
int BlockZ = (a_Chunk.GetPosZ() * cChunkDef::Width) + a_RelZ;
|
|
|
|
GetBlockCoordsBehindTheSign(a_Chunk.GetMeta(a_RelX, a_RelY, a_RelZ), BlockX, BlockZ);
|
2014-08-04 16:22:08 -04:00
|
|
|
BLOCKTYPE Type = a_ChunkInterface.GetBlock(BlockX, a_RelY, BlockZ);
|
2014-07-17 20:19:30 -04:00
|
|
|
|
2014-08-04 16:22:08 -04:00
|
|
|
return ((Type == E_BLOCK_WALLSIGN) || (Type == E_BLOCK_SIGN_POST) || cBlockInfo::IsSolid(Type));
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-18 16:41:48 -04:00
|
|
|
static void GetBlockCoordsBehindTheSign(NIBBLETYPE a_BlockMeta, int & a_BlockX, int & a_BlockZ)
|
2014-07-17 20:19:30 -04:00
|
|
|
{
|
|
|
|
switch (a_BlockMeta)
|
|
|
|
{
|
2014-07-18 16:41:48 -04:00
|
|
|
case 2: a_BlockZ++; break;
|
|
|
|
case 3: a_BlockZ--; break;
|
|
|
|
case 4: a_BlockX++; break;
|
|
|
|
case 5: a_BlockX--; break;
|
|
|
|
default: break;
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NIBBLETYPE DirectionToMetaData(eBlockFace a_Direction)
|
|
|
|
{
|
|
|
|
switch (a_Direction)
|
|
|
|
{
|
|
|
|
case 0x2: return 0x2;
|
|
|
|
case 0x3: return 0x3;
|
|
|
|
case 0x4: return 0x4;
|
|
|
|
case 0x5: return 0x5;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0x2;
|
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|