Call update_groupcaps from load_enchantments

This avoids the need to call the function from on_enchant for unbreaking
and efficiency.
This commit is contained in:
Elias Åström 2022-02-12 19:41:22 +01:00
parent d898b02c8b
commit a6c5c8a72a
2 changed files with 6 additions and 4 deletions

View File

@ -97,8 +97,9 @@ mcl_enchanting.enchantments.efficiency = {
weight = 10, weight = 10,
description = S("Increases mining speed."), description = S("Increases mining speed."),
curse = false, curse = false,
on_enchant = function(itemstack, level) on_enchant = function()
mcl_enchanting.update_groupcaps(itemstack) -- Updating digging speed is handled by update_groupcaps which
-- is called from load_enchantments.
end, end,
requires_tool = false, requires_tool = false,
treasure = false, treasure = false,
@ -671,8 +672,8 @@ mcl_enchanting.enchantments.unbreaking = {
tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level) tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level)
itemstack:get_meta():set_tool_capabilities(tool_capabilities) itemstack:get_meta():set_tool_capabilities(tool_capabilities)
-- Unbreaking for groupcaps is handled in this function. -- Updating digging durability is handled by update_groupcaps
mcl_enchanting.update_groupcaps(itemstack) -- which is called from load_enchantments.
end, end,
requires_tool = true, requires_tool = true,
treasure = false, treasure = false,

View File

@ -34,6 +34,7 @@ function mcl_enchanting.load_enchantments(itemstack, enchantments)
enchantment_def.on_enchant(itemstack, level) enchantment_def.on_enchant(itemstack, level)
end end
end end
mcl_enchanting.update_groupcaps(itemstack)
end end
tt.reload_itemstack_description(itemstack) tt.reload_itemstack_description(itemstack)
end end