summaryrefslogtreecommitdiffstats
path: root/src/Items/ItemPainting.h
diff options
context:
space:
mode:
authorEthan Jones <ethan@yasfu.net>2021-10-03 22:29:45 +0200
committerGitHub <noreply@github.com>2021-10-03 22:29:45 +0200
commitafe07fe0900e5e03f439656558a953acf16f35b8 (patch)
tree1946a7980c5799bc4e028e78c6747102e4b92fba /src/Items/ItemPainting.h
parentAuthenticator: avoid move assignments to self (#5315) (diff)
downloadcuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar.gz
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar.bz2
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar.lz
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar.xz
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.tar.zst
cuberite-afe07fe0900e5e03f439656558a953acf16f35b8.zip
Diffstat (limited to 'src/Items/ItemPainting.h')
-rw-r--r--src/Items/ItemPainting.h10
1 files changed, 9 insertions, 1 deletions
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))
{