1
0

Limit fortune level, style fixes

This commit is contained in:
Tiger Wang
2020-09-22 11:08:12 +01:00
parent a0dd311d02
commit 71b96ab921
8 changed files with 45 additions and 40 deletions

View File

@@ -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;
}