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 | |
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 '')
-rw-r--r-- | src/Items/ItemBigFlower.h | 23 | ||||
-rw-r--r-- | src/Items/ItemChest.h | 12 | ||||
-rw-r--r-- | src/Items/ItemHandler.cpp | 12 | ||||
-rw-r--r-- | src/Items/ItemSign.h | 3 |
4 files changed, 26 insertions, 24 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; } }; diff --git a/src/Items/ItemChest.h b/src/Items/ItemChest.h index d8cde2ae2..9f1a3f0d2 100644 --- a/src/Items/ItemChest.h +++ b/src/Items/ItemChest.h @@ -51,12 +51,9 @@ public: BLOCKTYPE ClickedBlock; NIBBLETYPE ClickedBlockMeta; a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); - if ( - BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision() || - BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(&a_Player, ClickedBlockMeta) - ) + cChunkInterface ChunkInterface(a_World.GetChunkMap()); + if (BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, ClickedBlockMeta)) { - cChunkInterface ChunkInterface(a_World.GetChunkMap()); BlockHandler(ClickedBlock)->OnDestroyedByPlayer(ChunkInterface, a_World, &a_Player, a_BlockX, a_BlockY, a_BlockZ); } else @@ -75,10 +72,7 @@ public: // Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed. // No need to do combinability (dblslab) checks, client will do that here. - if ( - !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision() && - !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta) - ) + if (BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, ClickedBlockMeta)) { // Tried to place a block into another? // Happens when you place a block aiming at side of block with a torch on it or stem beside it diff --git a/src/Items/ItemHandler.cpp b/src/Items/ItemHandler.cpp index 8e3d79506..b430e83ef 100644 --- a/src/Items/ItemHandler.cpp +++ b/src/Items/ItemHandler.cpp @@ -357,14 +357,11 @@ bool cItemHandler::OnPlayerPlace( NIBBLETYPE ClickedBlockMeta; a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); + cChunkInterface ChunkInterface(a_World.GetChunkMap()); // Check if the block ignores build collision (water, grass etc.): - if ( - BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision() || - BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(&a_Player, ClickedBlockMeta) - ) + if (BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, ClickedBlockMeta)) { - cChunkInterface ChunkInterface(a_World.GetChunkMap()); BlockHandler(ClickedBlock)->OnDestroyedByPlayer(ChunkInterface, a_World, &a_Player, a_BlockX, a_BlockY, a_BlockZ); } else @@ -383,10 +380,7 @@ bool cItemHandler::OnPlayerPlace( // Clicked on side of block, make sure that placement won't be cancelled if there is a slab able to be double slabbed. // No need to do combinability (dblslab) checks, client will do that here. - if ( - !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision() && - !BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(&a_Player, PlaceMeta) - ) + if (!BlockHandler(PlaceBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, PlaceMeta)) { // Tried to place a block into another? // Happens when you place a block aiming at side of block with a torch on it or stem beside it diff --git a/src/Items/ItemSign.h b/src/Items/ItemSign.h index 4c417947d..37ad4967b 100644 --- a/src/Items/ItemSign.h +++ b/src/Items/ItemSign.h @@ -32,7 +32,8 @@ public: BLOCKTYPE ClickedBlock; NIBBLETYPE ClickedBlockMeta; a_World.GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, ClickedBlock, ClickedBlockMeta); - bool isReplacingClickedBlock = BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision() || BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(&a_Player, ClickedBlockMeta); + cChunkInterface ChunkInterface(a_World.GetChunkMap()); + bool isReplacingClickedBlock = BlockHandler(ClickedBlock)->DoesIgnoreBuildCollision(ChunkInterface, { a_BlockX, a_BlockY, a_BlockZ }, a_Player, ClickedBlockMeta); // If the regular placement doesn't work, do no further processing: if (!super::OnPlayerPlace(a_World, a_Player, a_EquippedItem, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_CursorX, a_CursorY, a_CursorZ)) |