diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-22 12:08:12 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-09-23 15:34:15 +0200 |
commit | 71b96ab921bed0371d7c75ac4a2db99b94591de2 (patch) | |
tree | 618e9e37799cbf07a55f4a3950071e067358753f /src/Blocks/BlockHandler.cpp | |
parent | Added dtEnvitonment to player damage text (#4925) (diff) | |
download | cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.gz cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.bz2 cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.lz cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.xz cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.tar.zst cuberite-71b96ab921bed0371d7c75ac4a2db99b94591de2.zip |
Diffstat (limited to 'src/Blocks/BlockHandler.cpp')
-rw-r--r-- | src/Blocks/BlockHandler.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Blocks/BlockHandler.cpp b/src/Blocks/BlockHandler.cpp index 4272bc607..274460e50 100644 --- a/src/Blocks/BlockHandler.cpp +++ b/src/Blocks/BlockHandler.cpp @@ -649,16 +649,16 @@ bool cBlockHandler::ToolHasSilkTouch(const cItem * a_Tool) -unsigned int cBlockHandler::ToolFortuneLevel(const cItem * a_Tool) +unsigned char cBlockHandler::ToolFortuneLevel(const cItem * a_Tool) { - if (a_Tool != nullptr) + if ((a_Tool != nullptr) && ItemCategory::IsTool(a_Tool->m_ItemType)) { - return a_Tool->m_Enchantments.GetLevel(cEnchantments::enchFortune); - } - else // Not a tool - { - return 0; + // Return enchantment level, limited to avoid spawning excessive pickups (crashing the server) when modified items are used: + return std::min(8U, a_Tool->m_Enchantments.GetLevel(cEnchantments::enchFortune)); } + + // Not a tool: + return 0; } |