From ab4f0df5b9eebc101623bef46cf46709e4fc6c63 Mon Sep 17 00:00:00 2001 From: peterbell10 Date: Tue, 12 Sep 2017 21:47:09 +0100 Subject: [PATCH] Only allow rails to be placed where valid. Fixes #3507. --- src/Blocks/BlockRail.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h index 07483c9b3..9ee891830 100644 --- a/src/Blocks/BlockRail.h +++ b/src/Blocks/BlockRail.h @@ -36,7 +36,14 @@ public: { a_BlockType = m_BlockType; a_BlockMeta = FindMeta(a_ChunkInterface, a_BlockX, a_BlockY, a_BlockZ); - return true; + Vector3i Pos{ a_BlockX, a_BlockY, a_BlockZ }; + return a_Player.GetWorld()->DoWithChunkAt(Pos, + [this, Pos, &a_ChunkInterface](cChunk & a_Chunk) + { + auto RelPos = cChunkDef::AbsoluteToRelative(Pos); + return CanBeAt(a_ChunkInterface, RelPos.x, RelPos.y, RelPos.z, a_Chunk); + } + ); } virtual void OnPlaced(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) override