diff options
Diffstat (limited to 'src/Items')
-rw-r--r-- | src/Items/ItemItemFrame.h | 10 | ||||
-rw-r--r-- | src/Items/ItemPainting.h | 10 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/Items/ItemItemFrame.h b/src/Items/ItemItemFrame.h index f1f687461..0f7a4ee8c 100644 --- a/src/Items/ItemItemFrame.h +++ b/src/Items/ItemItemFrame.h @@ -40,6 +40,12 @@ public: return false; } + // Make sure the support block is a valid block to place an item frame on: + if (!cHangingEntity::IsValidSupportBlock(a_World->GetBlock(a_ClickedBlockPos))) + { + return false; + } + // Make sure block that will be occupied by the item frame is free now: const auto PlacePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace); BLOCKTYPE Block = a_World->GetBlock(PlacePos); @@ -48,8 +54,8 @@ public: return false; } - // Place the item frame: - auto ItemFrame = std::make_unique<cItemFrame>(a_ClickedBlockFace, PlacePos); + // An item frame, centred so pickups spawn nicely. + auto ItemFrame = std::make_unique<cItemFrame>(a_ClickedBlockFace, Vector3d(0.5, 0.5, 0.5) + PlacePos); auto ItemFramePtr = ItemFrame.get(); if (!ItemFramePtr->Initialize(std::move(ItemFrame), *a_World)) { diff --git a/src/Items/ItemPainting.h b/src/Items/ItemPainting.h index 78d9f040a..058f8d3b2 100644 --- a/src/Items/ItemPainting.h +++ b/src/Items/ItemPainting.h @@ -45,6 +45,12 @@ public: return false; } + // Make sure the support block is a valid block to place a painting on: + if (!cHangingEntity::IsValidSupportBlock(a_World->GetBlock(a_ClickedBlockPos))) + { + return false; + } + // Make sure block that will be occupied is free: auto PlacePos = AddFaceDirection(a_ClickedBlockPos, a_ClickedBlockFace); BLOCKTYPE PlaceBlockType = a_World->GetBlock(PlacePos); @@ -85,7 +91,9 @@ public: }; auto PaintingTitle = gPaintingTitlesList[a_World->GetTickRandomNumber(ARRAYCOUNT(gPaintingTitlesList) - 1)]; - auto Painting = std::make_unique<cPainting>(PaintingTitle, a_ClickedBlockFace, PlacePos); + + // A painting, centred so pickups spawn nicely. + auto Painting = std::make_unique<cPainting>(PaintingTitle, a_ClickedBlockFace, Vector3d(0.5, 0.5, 0.5) + PlacePos); auto PaintingPtr = Painting.get(); if (!PaintingPtr->Initialize(std::move(Painting), *a_World)) { |