summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockHandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Blocks/BlockHandler.cpp')
-rw-r--r--src/Blocks/BlockHandler.cpp14
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;
}