From 57da82524bc0b216f232c377e5451bcd187e2ec6 Mon Sep 17 00:00:00 2001 From: Max Luchterhand <52720531+maxluchterhand1@users.noreply.github.com> Date: Wed, 18 Mar 2020 16:59:28 +0000 Subject: Blocks only drop pickups when using correct tool (#4505) Co-authored-by: mluchterhand --- .gitignore | 2 ++ src/Chunk.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index f49727f3e..220134226 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ cloc.xsl *.sqlite /EveryNight.cmd /UploadLuaAPI.cmd +GPUCache AllFiles.lst # IDE Stuff @@ -104,6 +105,7 @@ ReleaseProfile/ *.dir/ CPackConfig.cmake CPackSourceConfig.cmake +cmake-build-debug # APIDump-generated status files: Server/cuberite_api.lua diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 75773c8b9..52464f4da 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -974,7 +974,13 @@ cItems cChunk::PickupsFromBlock(Vector3i a_RelPos, const cEntity * a_Digger, con GetBlockTypeMeta(a_RelPos, blockType, blockMeta); auto blockHandler = cBlockInfo::GetHandler(blockType); auto blockEntity = GetBlockEntityRel(a_RelPos); - auto pickups = blockHandler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool); + cItems pickups (0); + auto toolHandler = a_Tool ? a_Tool->GetHandler() : cItemHandler::GetItemHandler(E_ITEM_EMPTY); + auto canHarvestBlock = toolHandler->CanHarvestBlock(blockType); + if (canHarvestBlock) + { + pickups = blockHandler->ConvertToPickups(blockMeta, blockEntity, a_Digger, a_Tool); + } auto absPos = RelativeToAbsolute(a_RelPos); cRoot::Get()->GetPluginManager()->CallHookBlockToPickups(*m_World, absPos, blockType, blockMeta, blockEntity, a_Digger, a_Tool, pickups); return pickups; -- cgit v1.2.3