mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-04 23:31:05 +01:00
Add durability for bow & fishing rod
This commit is contained in:
parent
c501ff6e1d
commit
bb0080617a
3 changed files with 13 additions and 2 deletions
|
@ -25,6 +25,7 @@ tt.register_snippet(function(itemstring)
|
|||
end
|
||||
return s
|
||||
end)
|
||||
|
||||
tt.register_snippet(function(itemstring, _, itemstack)
|
||||
--local def = minetest.registered_items[itemstring]
|
||||
local s = ""
|
||||
|
@ -34,13 +35,18 @@ tt.register_snippet(function(itemstring, _, itemstack)
|
|||
s = s .. S("Armor points: @1", pts)
|
||||
s = s .. "\n"
|
||||
end
|
||||
local remaining_uses = use
|
||||
if itemstack then
|
||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
if unbreaking > 0 then
|
||||
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
|
||||
end
|
||||
remaining_uses = math.round(use - (itemstack:get_wear() * use) / 65535)
|
||||
end
|
||||
if use > 0 then
|
||||
if use ~= remaining_uses then
|
||||
use = remaining_uses .. "/" .. use -- implicit conversion from number to string
|
||||
end
|
||||
s = s .. S("Armor durability: @1", use)
|
||||
end
|
||||
if s == "" then
|
||||
|
@ -109,6 +115,9 @@ end)
|
|||
|
||||
tt.register_snippet(function(itemstring, _, itemstack)
|
||||
if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then
|
||||
return S("Durability: @1", S("@1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring))))
|
||||
local stack = itemstack or ItemStack(itemstring)
|
||||
local use = mcl_util.calculate_durability(stack)
|
||||
local remaining_use = math.round(use - (stack:get_wear() * use) / 65535)
|
||||
return S("Durability: @1", S("@1 uses", remaining_use .."/".. use))
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -485,6 +485,7 @@ mcl_experience.register_on_add_xp(function(player, xp)
|
|||
end
|
||||
|
||||
stack:set_wear(math.floor(new_wear))
|
||||
tt.reload_itemstack_description(stack) -- update tooltip
|
||||
inv:set_stack(list, index, stack)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
--Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr.
|
||||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
local FISHING_ROD_DURABILITY = 65
|
||||
|
||||
local bobber_ENTITY={
|
||||
physical = false,
|
||||
|
@ -38,7 +39,7 @@ local fish = function(itemstack, player, pointed_thing)
|
|||
local ent = nil
|
||||
local noent = true
|
||||
|
||||
local durability = 65
|
||||
local durability = FISHING_ROD_DURABILITY
|
||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
if unbreaking > 0 then
|
||||
durability = durability * (unbreaking + 1)
|
||||
|
|
Loading…
Reference in a new issue