Beds: derestrict clicking block face (#4863)
Ref: https://github.com/cuberite/cuberite/issues/4860#issuecomment-691545904
This commit is contained in:
parent
198407807f
commit
33f3c18bc1
@ -22,18 +22,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool IsPlaceable(void) override
|
virtual bool IsPlaceable(void) override
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
virtual bool GetBlocksToPlace(
|
virtual bool GetBlocksToPlace(
|
||||||
cWorld & a_World,
|
cWorld & a_World,
|
||||||
cPlayer & a_Player,
|
cPlayer & a_Player,
|
||||||
@ -44,25 +38,19 @@ public:
|
|||||||
sSetBlockVector & a_BlocksToPlace
|
sSetBlockVector & a_BlocksToPlace
|
||||||
) override
|
) override
|
||||||
{
|
{
|
||||||
// Can only be placed on the floor:
|
const auto BlockMeta = cBlockBedHandler::YawToMetaData(a_Player.GetYaw());
|
||||||
if (a_ClickedBlockFace != BLOCK_FACE_TOP)
|
const auto HeadPosition = a_PlacedBlockPos + cBlockBedHandler::MetaDataToDirection(BlockMeta);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The "foot" block:
|
|
||||||
NIBBLETYPE BlockMeta = cBlockBedHandler::YawToMetaData(a_Player.GetYaw());
|
|
||||||
a_BlocksToPlace.emplace_back(a_PlacedBlockPos, E_BLOCK_BED, BlockMeta);
|
|
||||||
|
|
||||||
|
// Vanilla only allows beds to be placed into air
|
||||||
// Check if there is empty space for the "head" block:
|
// Check if there is empty space for the "head" block:
|
||||||
// (Vanilla only allows beds to be placed into air)
|
if (a_World.GetBlock(HeadPosition) != E_BLOCK_AIR)
|
||||||
auto Direction = cBlockBedHandler::MetaDataToDirection(BlockMeta);
|
|
||||||
auto HeadPos = a_PlacedBlockPos + Direction;
|
|
||||||
if (a_World.GetBlock(HeadPos) != E_BLOCK_AIR)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
a_BlocksToPlace.emplace_back(HeadPos, E_BLOCK_BED, BlockMeta | 0x08);
|
|
||||||
|
// The "foot", and the "head" block:
|
||||||
|
a_BlocksToPlace.emplace_back(a_PlacedBlockPos, E_BLOCK_BED, BlockMeta);
|
||||||
|
a_BlocksToPlace.emplace_back(HeadPosition, E_BLOCK_BED, BlockMeta | 0x08);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user