mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-10-01 09:31:52 +02:00
Add durability for bow & fishing rod
This commit is contained in:
parent
c501ff6e1d
commit
bb0080617a
@ -25,6 +25,7 @@ tt.register_snippet(function(itemstring)
|
|||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
end)
|
end)
|
||||||
|
|
||||||
tt.register_snippet(function(itemstring, _, itemstack)
|
tt.register_snippet(function(itemstring, _, itemstack)
|
||||||
--local def = minetest.registered_items[itemstring]
|
--local def = minetest.registered_items[itemstring]
|
||||||
local s = ""
|
local s = ""
|
||||||
@ -34,13 +35,18 @@ tt.register_snippet(function(itemstring, _, itemstack)
|
|||||||
s = s .. S("Armor points: @1", pts)
|
s = s .. S("Armor points: @1", pts)
|
||||||
s = s .. "\n"
|
s = s .. "\n"
|
||||||
end
|
end
|
||||||
|
local remaining_uses = use
|
||||||
if itemstack then
|
if itemstack then
|
||||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||||
if unbreaking > 0 then
|
if unbreaking > 0 then
|
||||||
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
|
use = math.floor(use / (0.6 + 0.4 / (unbreaking + 1)))
|
||||||
end
|
end
|
||||||
|
remaining_uses = math.round(use - (itemstack:get_wear() * use) / 65535)
|
||||||
end
|
end
|
||||||
if use > 0 then
|
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)
|
s = s .. S("Armor durability: @1", use)
|
||||||
end
|
end
|
||||||
if s == "" then
|
if s == "" then
|
||||||
@ -109,6 +115,9 @@ end)
|
|||||||
|
|
||||||
tt.register_snippet(function(itemstring, _, itemstack)
|
tt.register_snippet(function(itemstring, _, itemstack)
|
||||||
if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then
|
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
|
||||||
end)
|
end)
|
||||||
|
@ -485,6 +485,7 @@ mcl_experience.register_on_add_xp(function(player, xp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
stack:set_wear(math.floor(new_wear))
|
stack:set_wear(math.floor(new_wear))
|
||||||
|
tt.reload_itemstack_description(stack) -- update tooltip
|
||||||
inv:set_stack(list, index, stack)
|
inv:set_stack(list, index, stack)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
--Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr.
|
--Fishing Rod, Bobber, and Flying Bobber mechanics and Bobber artwork by Rootyjr.
|
||||||
|
|
||||||
local S = minetest.get_translator(minetest.get_current_modname())
|
local S = minetest.get_translator(minetest.get_current_modname())
|
||||||
|
local FISHING_ROD_DURABILITY = 65
|
||||||
|
|
||||||
local bobber_ENTITY={
|
local bobber_ENTITY={
|
||||||
physical = false,
|
physical = false,
|
||||||
@ -38,7 +39,7 @@ local fish = function(itemstack, player, pointed_thing)
|
|||||||
local ent = nil
|
local ent = nil
|
||||||
local noent = true
|
local noent = true
|
||||||
|
|
||||||
local durability = 65
|
local durability = FISHING_ROD_DURABILITY
|
||||||
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
local unbreaking = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||||
if unbreaking > 0 then
|
if unbreaking > 0 then
|
||||||
durability = durability * (unbreaking + 1)
|
durability = durability * (unbreaking + 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user