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/ItemPainting.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Items/ItemPainting.h') 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(PaintingTitle, a_ClickedBlockFace, PlacePos); + + // A painting, centred so pickups spawn nicely. + auto Painting = std::make_unique(PaintingTitle, a_ClickedBlockFace, Vector3d(0.5, 0.5, 0.5) + PlacePos); auto PaintingPtr = Painting.get(); if (!PaintingPtr->Initialize(std::move(Painting), *a_World)) { -- cgit v1.2.3