2013-07-29 07:13:03 -04:00
|
|
|
|
2017-07-07 03:31:45 -04:00
|
|
|
// BlockBed.h
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
#pragma once
|
|
|
|
|
2017-07-07 03:31:45 -04:00
|
|
|
#include "BlockEntity.h"
|
2019-10-16 04:06:34 -04:00
|
|
|
#include "Mixins.h"
|
2015-02-08 16:21:48 -05:00
|
|
|
#include "ChunkInterface.h"
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
2017-08-07 03:08:27 -04:00
|
|
|
class cEntity;
|
2014-09-26 13:13:19 -04:00
|
|
|
class cPlayer;
|
|
|
|
class cWorldInterface;
|
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class cBlockBedHandler :
|
2020-04-10 07:25:36 -04:00
|
|
|
public cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01>
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
2020-04-13 12:38:06 -04:00
|
|
|
using Super = cYawRotator<cBlockEntityHandler, 0x03, 0x02, 0x03, 0x00, 0x01>;
|
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
|
|
|
|
|
|
|
cBlockBedHandler(BLOCKTYPE a_BlockType):
|
2020-04-13 12:38:06 -04:00
|
|
|
Super(a_BlockType)
|
2013-07-29 07:13:03 -04:00
|
|
|
{
|
|
|
|
}
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2017-07-07 03:31:45 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Overrides:
|
2020-04-21 16:19:22 -04:00
|
|
|
virtual void OnBroken(
|
|
|
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface,
|
|
|
|
const Vector3i a_BlockPos,
|
|
|
|
BLOCKTYPE a_OldBlockType, NIBBLETYPE a_OldBlockMeta
|
|
|
|
) override;
|
|
|
|
|
|
|
|
virtual bool OnUse(
|
|
|
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
|
|
|
|
const Vector3i a_ClickedBlockPos,
|
|
|
|
eBlockFace a_ClickedBlockFace,
|
|
|
|
const Vector3i a_CursorPos
|
|
|
|
) override;
|
|
|
|
|
|
|
|
virtual cItems ConvertToPickups(
|
|
|
|
NIBBLETYPE a_BlockMeta,
|
|
|
|
cBlockEntity * a_BlockEntity,
|
|
|
|
const cEntity * a_Digger,
|
|
|
|
const cItem * a_Tool
|
|
|
|
) override;
|
|
|
|
|
|
|
|
virtual void OnPlacedByPlayer(
|
|
|
|
cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer & a_Player,
|
|
|
|
const sSetBlock & a_BlockChange
|
|
|
|
) override;
|
2019-10-16 04:06:34 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2017-07-07 03:31:45 -04:00
|
|
|
|
2013-07-29 07:13:03 -04:00
|
|
|
|
|
|
|
static Vector3i MetaDataToDirection(NIBBLETYPE a_MetaData)
|
|
|
|
{
|
|
|
|
switch (a_MetaData)
|
|
|
|
{
|
2019-10-16 04:06:34 -04:00
|
|
|
case 0: return Vector3i( 0, 0, 1);
|
|
|
|
case 1: return Vector3i(-1, 0, 0);
|
|
|
|
case 2: return Vector3i( 0, 0, -1);
|
|
|
|
case 3: return Vector3i( 1, 0, 0);
|
2013-07-29 07:13:03 -04:00
|
|
|
}
|
|
|
|
return Vector3i();
|
|
|
|
}
|
2015-02-08 16:21:48 -05:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-10-11 05:02:53 -04:00
|
|
|
static void SetBedOccupationState(cChunkInterface & a_ChunkInterface, Vector3i a_BedPosition, bool a_IsOccupied)
|
2015-02-08 16:21:48 -05:00
|
|
|
{
|
2017-11-20 06:13:11 -05:00
|
|
|
auto Meta = a_ChunkInterface.GetBlockMeta(a_BedPosition);
|
2015-02-08 16:21:48 -05:00
|
|
|
if (a_IsOccupied)
|
|
|
|
{
|
|
|
|
Meta |= 0x04; // Where 0x4 = occupied bit
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Meta &= 0x0b; // Clear the "occupied" bit of the bed's block
|
|
|
|
}
|
|
|
|
|
2019-10-11 05:02:53 -04:00
|
|
|
a_ChunkInterface.SetBlockMeta(a_BedPosition, Meta);
|
2015-02-08 16:21:48 -05:00
|
|
|
}
|
2015-06-30 10:50:15 -04:00
|
|
|
|
2019-10-16 04:06:34 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-07 03:31:45 -04:00
|
|
|
|
2015-06-30 10:50:15 -04:00
|
|
|
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override
|
|
|
|
{
|
|
|
|
UNUSED(a_Meta);
|
|
|
|
return 28;
|
|
|
|
}
|
2013-07-29 07:13:03 -04:00
|
|
|
} ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|