From a516eccd6d6f5363b9613da6e4add9a46b4b96a8 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 2 Nov 2020 15:09:11 +0100 Subject: [PATCH] Unbreaking for Bows --- mods/CORE/mcl_enchanting/enchantments.lua | 2 +- mods/ITEMS/mcl_bows/bow.lua | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mods/CORE/mcl_enchanting/enchantments.lua b/mods/CORE/mcl_enchanting/enchantments.lua index 63316b8d8b..07d302e3a5 100644 --- a/mods/CORE/mcl_enchanting/enchantments.lua +++ b/mods/CORE/mcl_enchanting/enchantments.lua @@ -460,7 +460,7 @@ mcl_enchanting.enchantments.thorns = { requires_tool = false, } --- implemented via on_enchant; Unimplemented for Bows, Armor and Fishing Rods +-- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows, unimplemented Armor and Fishing Rods mcl_enchanting.enchantments.unbreaking = { name = "Unbreaking", max_level = 3, diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index cf7efb623e..efa3caeb5c 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -237,7 +237,12 @@ controls.register_on_release(function(player, key, time) end if has_shot and not minetest.is_creative_enabled(player:get_player_name()) then - wielditem:add_wear(65535/BOW_DURABILITY) + local durability = BOW_DURABILITY + local unbreaking = mcl_enchanting.get_enchantment(wielditem, "unbreaking") + if unbreaking > 0 then + durability = durability * (unbreaking + 1) + end + wielditem:add_wear(65535/durability) end player:set_wielded_item(wielditem) reset_bow_state(player, true)