summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemBed.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/Items/ItemBed.h')
-rw-r--r--src/Items/ItemBed.h28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/Items/ItemBed.h b/src/Items/ItemBed.h
index 9c79a134a..98f9f614f 100644
--- a/src/Items/ItemBed.h
+++ b/src/Items/ItemBed.h
@@ -22,18 +22,12 @@ public:
}
-
-
-
virtual bool IsPlaceable(void) override
{
return true;
}
-
-
-
virtual bool GetBlocksToPlace(
cWorld & a_World,
cPlayer & a_Player,
@@ -44,25 +38,19 @@ public:
sSetBlockVector & a_BlocksToPlace
) override
{
- // Can only be placed on the floor:
- if (a_ClickedBlockFace != BLOCK_FACE_TOP)
- {
- return false;
- }
-
- // The "foot" block:
- NIBBLETYPE BlockMeta = cBlockBedHandler::YawToMetaData(a_Player.GetYaw());
- a_BlocksToPlace.emplace_back(a_PlacedBlockPos, E_BLOCK_BED, BlockMeta);
+ const auto BlockMeta = cBlockBedHandler::YawToMetaData(a_Player.GetYaw());
+ const auto HeadPosition = a_PlacedBlockPos + cBlockBedHandler::MetaDataToDirection(BlockMeta);
+ // Vanilla only allows beds to be placed into air
// Check if there is empty space for the "head" block:
- // (Vanilla only allows beds to be placed into air)
- auto Direction = cBlockBedHandler::MetaDataToDirection(BlockMeta);
- auto HeadPos = a_PlacedBlockPos + Direction;
- if (a_World.GetBlock(HeadPos) != E_BLOCK_AIR)
+ if (a_World.GetBlock(HeadPosition) != E_BLOCK_AIR)
{
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;
}
};