2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "BlockHandler.h"
|
2013-08-19 05:39:13 -04:00
|
|
|
#include "../Entities/Player.h"
|
2014-02-01 09:01:13 -05:00
|
|
|
#include "Chunk.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-17 20:19:30 -04:00
|
|
|
class cBlockSignPostHandler :
|
2013-07-29 07:13:03 -04:00
|
|
|
public cBlockHandler
|
|
|
|
{
|
2014-07-18 16:41:48 -04:00
|
|
|
typedef cBlockHandler super;
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
public:
|
2014-07-18 16:41:48 -04:00
|
|
|
cBlockSignPostHandler(BLOCKTYPE a_BlockType) :
|
|
|
|
super(a_BlockType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
2014-07-17 20:19:30 -04:00
|
|
|
|
2013-07-29 07:13:03 -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
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
|
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
|
|
|
|
{
|
|
|
|
if (a_RelY <= 0)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-08-04 16:22:08 -04:00
|
|
|
BLOCKTYPE Type = a_Chunk.GetBlock(a_RelX, a_RelY - 1, a_RelZ);
|
2014-07-17 20:19:30 -04:00
|
|
|
|
2014-10-23 03:07:20 -04:00
|
|
|
return ((Type == E_BLOCK_SIGN_POST) || (Type == E_BLOCK_WALLSIGN) || cBlockInfo::IsSolid(Type));
|
2014-07-17 20:19:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-04-04 03:56:57 -04:00
|
|
|
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
a_Rotation += 180 + (180 / 16); // So it's not aligned with axis
|
|
|
|
if (a_Rotation > 360)
|
|
|
|
{
|
|
|
|
a_Rotation -= 360;
|
|
|
|
}
|
|
|
|
|
|
|
|
a_Rotation = (a_Rotation / 360) * 16;
|
|
|
|
|
|
|
|
return ((char)a_Rotation) % 16;
|
|
|
|
}
|
2013-07-29 15:42:05 -04:00
|
|
|
|
|
|
|
|
2014-03-25 17:17:05 -04:00
|
|
|
virtual NIBBLETYPE MetaRotateCW(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
2014-06-22 15:51:34 -04:00
|
|
|
return (a_Meta + 4) & 0x0f;
|
2014-03-25 17:17:05 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual NIBBLETYPE MetaRotateCCW(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
2014-06-22 15:51:34 -04:00
|
|
|
return (a_Meta + 12) & 0x0f;
|
2014-03-25 17:17:05 -04:00
|
|
|
}
|
2014-03-29 10:00:44 -04:00
|
|
|
|
2014-07-18 16:41:48 -04:00
|
|
|
|
2014-03-29 10:00:44 -04:00
|
|
|
virtual NIBBLETYPE MetaMirrorXY(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
2014-07-18 16:41:48 -04:00
|
|
|
// Mirrors signs over the XY plane (North-South Mirroring)
|
2014-03-29 10:00:44 -04:00
|
|
|
|
2014-07-18 16:41:48 -04:00
|
|
|
// There are 16 meta values which correspond to different directions.
|
|
|
|
// These values are equated to angles on a circle; 0x08 = 180 degrees.
|
2014-06-22 15:51:34 -04:00
|
|
|
return (a_Meta < 0x08) ? (0x08 + a_Meta) : (0x08 - a_Meta);
|
2014-03-29 10:00:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
virtual NIBBLETYPE MetaMirrorYZ(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
2014-07-18 16:41:48 -04:00
|
|
|
// Mirrors signs over the YZ plane (East-West Mirroring)
|
2014-03-29 10:00:44 -04:00
|
|
|
|
2014-07-18 16:41:48 -04:00
|
|
|
// There are 16 meta values which correspond to different directions.
|
|
|
|
// These values are equated to angles on a circle; 0x10 = 360 degrees.
|
2014-03-29 10:00:44 -04:00
|
|
|
return 0x10 - a_Meta;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|