summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-09-13 12:58:39 +0200
committerGitHub <noreply@github.com>2020-09-13 12:58:39 +0200
commit33f3c18bc1646496b95f7652ffc292c9aade7a05 (patch)
tree28a7527c58c52052980701839f4d5422e4317158 /src
parentReverse order of ChunkSender priorities (#4858) (diff)
downloadcuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar.gz
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar.bz2
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar.lz
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar.xz
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.tar.zst
cuberite-33f3c18bc1646496b95f7652ffc292c9aade7a05.zip
Diffstat (limited to '')
-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;
}
};