diff options
author | peterbell10 <peterbell10@live.co.uk> | 2017-07-07 16:37:53 +0200 |
---|---|---|
committer | Lukas Pioch <lukas@zgow.de> | 2017-07-07 16:37:53 +0200 |
commit | bbf5bec817c6c9824155c15d34806db152d5ed43 (patch) | |
tree | 80f9532ae5814da4c168dbf7138ea9a289fc4a8c /src/Items/ItemBigFlower.h | |
parent | Added bed entity (#3823) (diff) | |
download | cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar.gz cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar.bz2 cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar.lz cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar.xz cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.tar.zst cuberite-bbf5bec817c6c9824155c15d34806db152d5ed43.zip |
Diffstat (limited to 'src/Items/ItemBigFlower.h')
-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; } }; |