2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 09:41:47 -04:00
|
|
|
#pragma once
|
2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 09:41:47 -04:00
|
|
|
#include "BlockHandler.h"
|
|
|
|
#include "../World.h"
|
|
|
|
#include "../Sign.h"
|
|
|
|
#include "../Player.h"
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockBedHandler :
|
|
|
|
public cBlockHandler
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
public:
|
2012-10-03 04:52:11 -04:00
|
|
|
cBlockBedHandler(BLOCKTYPE a_BlockType)
|
|
|
|
: cBlockHandler(a_BlockType)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual void OnPlacedByPlayer(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override;
|
2012-10-03 04:52:11 -04:00
|
|
|
virtual void OnDestroyed(cWorld * a_World, int a_BlockX, int a_BlockY, int a_BlockZ) override;
|
2013-01-11 23:46:01 -05:00
|
|
|
virtual void OnUse(cWorld * a_World, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, char a_BlockFace, int a_CursorX, int a_CursorY, int a_CursorZ) override;
|
2012-09-29 09:41:47 -04:00
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
virtual bool IsUseable(void) override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-09-29 16:43:42 -04:00
|
|
|
return true;
|
2012-09-29 09:41:47 -04:00
|
|
|
}
|
2012-10-01 17:08:15 -04:00
|
|
|
|
2012-09-29 16:43:42 -04:00
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
// Reset meta to zero
|
|
|
|
a_Pickups.push_back(cItem(E_ITEM_BED, 1, 0));
|
2012-09-29 09:41:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
virtual bool DoesAllowBlockOnTop() override
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-09-29 16:43:42 -04:00
|
|
|
// Bed specific helper functions
|
2013-03-09 09:35:43 -05:00
|
|
|
static NIBBLETYPE RotationToMetaData(double a_Rotation)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
|
|
|
a_Rotation += 180 + (180/4); // So its not aligned with axis
|
2013-03-09 09:35:43 -05:00
|
|
|
if( a_Rotation > 360 ) a_Rotation -= 360;
|
2012-09-29 09:41:47 -04:00
|
|
|
|
2013-03-09 09:35:43 -05:00
|
|
|
a_Rotation = (a_Rotation / 360) * 4;
|
2012-09-29 09:41:47 -04:00
|
|
|
|
2013-03-09 09:35:43 -05:00
|
|
|
return ((char)a_Rotation + 2) % 4;
|
2012-09-29 09:41:47 -04:00
|
|
|
}
|
|
|
|
|
2012-10-01 17:08:15 -04:00
|
|
|
|
|
|
|
static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
switch (a_MetaData)
|
2012-09-29 09:41:47 -04:00
|
|
|
{
|
2012-10-01 17:08:15 -04:00
|
|
|
case 0: // south +z
|
|
|
|
return Vector3i(0, 0, 1);
|
|
|
|
case 1: // west -x
|
|
|
|
return Vector3i(-1, 0, 0);
|
|
|
|
case 2: // north -z
|
|
|
|
return Vector3i(0, 0, -1);
|
|
|
|
case 3: // east +x
|
|
|
|
return Vector3i(1, 0, 0);
|
2012-09-29 09:41:47 -04:00
|
|
|
};
|
|
|
|
return Vector3i();
|
|
|
|
}
|
2012-10-01 17:08:15 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|