From afe07fe0900e5e03f439656558a953acf16f35b8 Mon Sep 17 00:00:00 2001 From: Ethan Jones Date: Sun, 3 Oct 2021 14:29:45 -0600 Subject: Prevent placing of hangables on illegal blocks and break when support block broken (#5301) + Prevent placing of hangables on illegal items and break when support block is broken Co-authored-by: Tiger Wang --- src/Items/ItemItemFrame.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/Items/ItemItemFrame.h') 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(a_ClickedBlockFace, PlacePos); + // An item frame, centred so pickups spawn nicely. + auto ItemFrame = std::make_unique(a_ClickedBlockFace, Vector3d(0.5, 0.5, 0.5) + PlacePos); auto ItemFramePtr = ItemFrame.get(); if (!ItemFramePtr->Initialize(std::move(ItemFrame), *a_World)) { -- cgit v1.2.3