diff options
Diffstat (limited to '')
-rw-r--r-- | src/Items/ItemBigFlower.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/Items/ItemBigFlower.h b/src/Items/ItemBigFlower.h index f7171f2bc..81a1d54ce 100644 --- a/src/Items/ItemBigFlower.h +++ b/src/Items/ItemBigFlower.h @@ -34,17 +34,30 @@ public: sSetBlockVector & a_BlocksToSet ) override { - // Can only be placed on the floor: - if ((a_BlockY < 0) || (a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ) == E_BLOCK_AIR)) + // Can only be placed on dirt: + if ((a_BlockY <= 0) || !IsBlockTypeOfDirt(a_World.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ))) { return false; } - a_BlocksToSet.emplace_back(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BIG_FLOWER, a_EquippedItem.m_ItemDamage & 0x07); - if (a_BlockY < cChunkDef::Height - 1) + // Needs at least two free blocks to build in + if (a_BlockY >= cChunkDef::Height - 1) { - a_BlocksToSet.emplace_back(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_BIG_FLOWER, (a_EquippedItem.m_ItemDamage & 0x07) | 0x08); + return false; } + + BLOCKTYPE TopType; + NIBBLETYPE TopMeta; + a_World.GetBlockTypeMeta(a_BlockX, a_BlockY + 1, a_BlockZ, TopType, TopMeta); + cChunkInterface ChunkInterface(a_World.GetChunkMap()); + + if (!BlockHandler(TopType)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY + 1, a_BlockZ }, a_Player, TopMeta)) + { + return false; + } + + a_BlocksToSet.emplace_back(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_BIG_FLOWER, a_EquippedItem.m_ItemDamage & 0x07); + a_BlocksToSet.emplace_back(a_BlockX, a_BlockY + 1, a_BlockZ, E_BLOCK_BIG_FLOWER, E_META_BIG_FLOWER_TOP); return true; } }; |