diff options
author | bibo38 <bibo38@github.com> | 2015-11-05 12:36:51 +0100 |
---|---|---|
committer | bibo38 <bibo38@github.com> | 2015-11-07 17:23:02 +0100 |
commit | ceec6c936d5608049da5532572cefaea242fa16e (patch) | |
tree | b2859951d74df5ce9a57d45955380f0942be0380 /src/Blocks/BlockPiston.cpp | |
parent | Implemented the basic slime block pulling (diff) | |
download | cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar.gz cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar.bz2 cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar.lz cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar.xz cuberite-ceec6c936d5608049da5532572cefaea242fa16e.tar.zst cuberite-ceec6c936d5608049da5532572cefaea242fa16e.zip |
Diffstat (limited to 'src/Blocks/BlockPiston.cpp')
-rw-r--r-- | src/Blocks/BlockPiston.cpp | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/Blocks/BlockPiston.cpp b/src/Blocks/BlockPiston.cpp index cb56cc0d8..601e0999d 100644 --- a/src/Blocks/BlockPiston.cpp +++ b/src/Blocks/BlockPiston.cpp @@ -107,6 +107,12 @@ bool cBlockPistonHandler::CanPushBlock( return true; } + if(!a_RequirePushable && cBlockInfo::IsPistonBreakable(currBlock)) + { + // Block should not be broken, when it's not in the pushing direction + return true; + } + if (!CanPush(currBlock, currMeta)) { return !a_RequirePushable; @@ -273,7 +279,7 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ } std::unordered_set<Vector3i, VectorHasher<int>> pushedBlocks; - if (!CanPushBlock(a_BlockX, a_BlockY, a_BlockZ, a_World, true, pushedBlocks, pistonMeta)) + if (!CanPushBlock(a_BlockX, a_BlockY, a_BlockZ, a_World, false, pushedBlocks, pistonMeta)) { // Not pushable, bail out return; @@ -300,8 +306,19 @@ void cBlockPistonHandler::RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ AddPistonDir(moveX, moveY, moveZ, pistonMeta, 1); - // TODO Do not allow pisons to pull breakable blocks - a_World->SetBlock(moveX, moveY, moveZ, moveBlock, moveMeta); + if (cBlockInfo::IsPistonBreakable(moveBlock)) + { + cBlockHandler * Handler = BlockHandler(moveBlock); + if (Handler->DoesDropOnUnsuitable()) + { + cChunkInterface ChunkInterface(a_World->GetChunkMap()); + cBlockInServerPluginInterface PluginInterface(*a_World); + Handler->DropBlock(ChunkInterface, *a_World, PluginInterface, nullptr, moveX, moveY, moveZ); + } + } else + { + a_World->SetBlock(moveX, moveY, moveZ, moveBlock, moveMeta); + } } } |